fix: networking fixes + add server

This commit is contained in:
2026-09-25 13:43:05 +01:00
parent faf3a3edea
commit d24c73d4c7
13 changed files with 129 additions and 36 deletions
@@ -14,7 +14,7 @@
#include "..\..\TexturePackRepository.h"
#include "..\..\TexturePack.h"
#include "..\Network\SessionInfo.h"
#include "..\..\Common\Network\NetworkSocketLayer.h"
#include "..\..\Common\Network\NetworkSocketLayer.h"
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
#include "Common\Network\Sony\SonyHttp.h"
#include "Common\Network\Sony\SonyRemoteStorage.h"
@@ -413,6 +413,8 @@ void UIScene_LoadOrJoinMenu::Initialise()
m_iDefaultButtonsC = 0;
m_iMashUpButtonsC=0;
m_iServerDefaultButtonsC = 0;
// Check if we're in the trial version
if(ProfileManager.IsFullVersion()==false)
{
@@ -935,8 +937,13 @@ void UIScene_LoadOrJoinMenu::AddDefaultButtons()
m_iMashUpButtonsC=0;
m_generators.clear();
m_iServerDefaultButtonsC = 0;
m_buttonListSaves.addItem(app.GetString(IDS_CREATE_NEW_WORLD));
// hard-coded FOR NOW!
m_buttonListGames.addItem(L"Add Server");
m_iDefaultButtonsC++;
m_iServerDefaultButtonsC++;
int i = 0;
@@ -1391,23 +1398,43 @@ void UIScene_LoadOrJoinMenu::handlePress(F64 controlId, F64 childId)
//CD - Added for audio
ui.PlayUISFX(eSFX_Press);
int nIndex = (int)childId;
if(nIndex == ADD_SERVER_BUTTON_INDEX)
{
int nIndex = (int)childId;
m_iGameListIndex = nIndex;
CheckAndJoinGame(nIndex);
InputManager.RequestKeyboard(app.GetString(IDS_SIGN_TITLE),L"192.168.",(DWORD)m_iPad,15,&UIScene_LoadOrJoinMenu::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_IP_Address);
}
else
{
m_iGameListIndex = nIndex - m_iServerDefaultButtonsC;
CheckAndJoinGame(nIndex - m_iServerDefaultButtonsC);
}
break;
}
}
}
int UIScene_LoadOrJoinMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes)
{
// 4J HEG - No reason to set value if keyboard was cancelled
UIScene_LoadOrJoinMenu *pClass=(UIScene_LoadOrJoinMenu *)lpParam;
pClass->m_bIgnoreInput = false;
if (bRes)
{
uint16_t pchText[128];
ZeroMemory(pchText, 128 * sizeof(uint16_t) );
InputManager.GetText(pchText);
CGameNetworkManager::AddServer((const wchar_t *)pchText, NETWORK_LAN_DEFAULT_PORT, (const wchar_t *)pchText);
}
return 0;
}
void UIScene_LoadOrJoinMenu::CheckAndJoinGame(int gameIndex)
{
if( m_buttonListGames.getItemCount() > 0 && gameIndex < m_currentSessions->size() )
{
#if defined(__PS3__) || defined(__ORBIS__) || defined(__PSVITA__)
const bool bManualJoin = (g_MultiplayerJoin == true);
const bool bManualJoin = (g_MultiplayerJoin == true);
// 4J-PB - is the player allowed to join games?
bool noUGC=false;
bool bContentRestricted=false;
@@ -1686,10 +1713,14 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList()
FriendSessionInfo *pSelectedSession = NULL;
if(DoesGamesListHaveFocus() && m_buttonListGames.getItemCount() > 0)
unsigned int nIndex = 0;
if(DoesGamesListHaveFocus() && (m_buttonListGames.getItemCount() - m_iServerDefaultButtonsC) > 0)
{
unsigned int nIndex = m_buttonListGames.getCurrentSelection();
pSelectedSession = m_currentSessions->at( nIndex );
nIndex = m_buttonListGames.getCurrentSelection();
if (nIndex >= m_iServerDefaultButtonsC)
{
pSelectedSession = m_currentSessions->at( nIndex - m_iServerDefaultButtonsC );
}
}
SessionID selectedSessionId;
@@ -1714,7 +1745,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList()
BOOL gamesListHasFocus = DoesGamesListHaveFocus();
if(filteredListSize > 0)
if(filteredListSize > 0 || m_iServerDefaultButtonsC > 0)
{
#if TO_BE_IMPLEMENTED
if( !m_pGamesList->IsEnabled() )
@@ -1742,11 +1773,24 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList()
// clear out the games list and re-fill
m_buttonListGames.clearList();
if( filteredListSize > 0 )
m_iServerDefaultButtonsC = 0;
m_buttonListGames.addItem(app.GetString(IDS_ACTION_BAN_LEVEL_TITLE));
m_iServerDefaultButtonsC++;
if( filteredListSize > 0 )
{
// Reset the focus to the selected session if it still exists
unsigned int sessionIndex = 0;
m_buttonListGames.setCurrentSelection(0);
if (DoesGamesListHaveFocus())
{
m_buttonListGames.setCurrentSelection( 0 );
if (nIndex >= m_iServerDefaultButtonsC)
{
m_buttonListGames.setCurrentSelection( nIndex );
}
}
for( AUTO_VAR(it, m_currentSessions->begin()); it < m_currentSessions->end(); ++it)
{
@@ -1807,9 +1851,9 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList()
m_buttonListGames.addItem( sessionInfo->displayLabel, textureName );
if(memcmp( &selectedSessionId, &sessionInfo->sessionId, sizeof(SessionID) ) == 0)
if(memcmp( &selectedSessionId, &sessionInfo->sessionId, sizeof(SessionID) ) == 0 && DoesGamesListHaveFocus())
{
m_buttonListGames.setCurrentSelection(sessionIndex);
m_buttonListGames.setCurrentSelection(sessionIndex + m_iServerDefaultButtonsC);
break;
}
++sessionIndex;