From 3311434d41021884dac616f5428aa528c9ec7979 Mon Sep 17 00:00:00 2001
From: daco65 <daco65@gmail.com>
Date: Sat, 15 Aug 2009 14:34:52 +0000
Subject: [PATCH] NETPLAY : display game name correctly in gui , added netplay
 to logmanager (netplay is horribly in seeing what its doing). hoping to get
 netplay to work again cause its borked LLE: warning fix (would linux hate {}
 ? )

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3987 8ced0084-cf51-0410-be5f-012b33b47a6e
---
 Source/Core/Common/Src/Log.h                            | 1 +
 Source/Core/Common/Src/LogManager.cpp                   | 1 +
 Source/Core/DolphinWX/Src/NetFunctions.cpp              | 1 +
 Source/Core/DolphinWX/Src/NetSockets.cpp                | 8 ++++++--
 Source/Core/DolphinWX/Src/NetWindow.cpp                 | 9 +++++++--
 Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp | 4 ++--
 6 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/Source/Core/Common/Src/Log.h b/Source/Core/Common/Src/Log.h
index ca2ff1ce75..a24f7e65f0 100644
--- a/Source/Core/Common/Src/Log.h
+++ b/Source/Core/Common/Src/Log.h
@@ -69,6 +69,7 @@ enum LOG_TYPE {
 	WII_IPC_STM,
 	WII_IPC_WIIMOTE,
 	WIIMOTE,
+	NETPLAY,
 
 	NUMBER_OF_LOGS // Must be last
 };
diff --git a/Source/Core/Common/Src/LogManager.cpp b/Source/Core/Common/Src/LogManager.cpp
index 6fb94f975f..d51f4d18ac 100644
--- a/Source/Core/Common/Src/LogManager.cpp
+++ b/Source/Core/Common/Src/LogManager.cpp
@@ -72,6 +72,7 @@ LogManager::LogManager()\
 	m_Log[LogTypes::WII_IPC_WIIMOTE]	= new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE");
 	m_Log[LogTypes::ACTIONREPLAY]		= new LogContainer("ActionReplay",	"ActionReplay");	
 	m_Log[LogTypes::MEMCARD_MANAGER]	= new LogContainer("MemCard Manger", "MemCard Manger");
+	m_Log[LogTypes::NETPLAY]			= new LogContainer("NETPLAY"	,	"Netplay");
 
 	m_fileLog = new FileLogListener(MAIN_LOG_FILE);
 	m_consoleLog = new ConsoleListener();
diff --git a/Source/Core/DolphinWX/Src/NetFunctions.cpp b/Source/Core/DolphinWX/Src/NetFunctions.cpp
index 7570d7bd1e..4c30cce255 100644
--- a/Source/Core/DolphinWX/Src/NetFunctions.cpp
+++ b/Source/Core/DolphinWX/Src/NetFunctions.cpp
@@ -415,6 +415,7 @@ void NetPlay::ChangeSelectedGame(std::string game)
 		m_selectedGame = game;
 		UpdateNetWindow(false);
 		m_Logging->AppendText(wxString::Format(wxT("*Game has been changed to : %s\n"), game.c_str()));
+		NOTICE_LOG(NETPLAY,"Game has been changed to : %s \n",game.c_str());
 	}
 }
 
diff --git a/Source/Core/DolphinWX/Src/NetSockets.cpp b/Source/Core/DolphinWX/Src/NetSockets.cpp
index a4523bf562..46689ff593 100644
--- a/Source/Core/DolphinWX/Src/NetSockets.cpp
+++ b/Source/Core/DolphinWX/Src/NetSockets.cpp
@@ -405,7 +405,7 @@ void *ClientSide::Entry()
 		unsigned char value;
 		size_t val_sz;
 		m_socket.Receive((char *)&value, 1, val_sz);
-		
+		// TODO : fix it. for some odd reason value is 1 instead of 16 making the connection "not successfull"
 		if (value == 0x16)	// UDP connection successful
 		{
 			Event->AppendText(_("Connection successful !\n"));
@@ -414,7 +414,7 @@ void *ClientSide::Entry()
 		}
 		else
 		{
-			Event->AppendText(_("UDP Connection FAILED !\nERROR : Unable to establish UDP Connection, please Check UDP Port forwarding !"));
+			Event->AppendText(_("UDP Connection FAILED !\nERROR : Unable to establish UDP Connection, please Check UDP Port forwarding !\n"));
 			m_socket.Close();
 			Event->SendEvent(HOST_ERROR);
 			return NULL;
@@ -553,7 +553,11 @@ void ClientSide::CheckGameFound()
 		m_socket.Send((const char *)&send_value, 1);
 
 		for (int i = 0; i < 2; i++)
+		{
 			Event->AppendText(_("WARNING : You do not have the Selected Game !\n"));
+			NOTICE_LOG(NETPLAY,"Game '%s' not found!",m_selectedgame);
+			
+		}			
 	}
 }
 
diff --git a/Source/Core/DolphinWX/Src/NetWindow.cpp b/Source/Core/DolphinWX/Src/NetWindow.cpp
index 99802c8c82..0ea88e6120 100644
--- a/Source/Core/DolphinWX/Src/NetWindow.cpp
+++ b/Source/Core/DolphinWX/Src/NetWindow.cpp
@@ -127,7 +127,9 @@ void NetPlay::OnHost(wxCommandEvent& WXUNUSED(event))
 		m_nick = m_nick.substr(0 , 255);
 
 	m_NetModel = m_NetMode->GetSelection();
+	//Note By DacoTaco : selection starts with 0 instead of 1 ? ( the +1 is needed)
 	m_selectedGame = std::string(m_GameList_str[m_GameList->GetSelection()].mb_str());
+	NOTICE_LOG(NETPLAY,"Game has been set to : %s \n",m_selectedGame.c_str());
 
 	// Create the listening socket
 	sf::SocketTCP sock_server;
@@ -358,7 +360,10 @@ void NetPlay::UpdateNetWindow(bool update_infos, wxString infos)
 	else
 	{
 		m_critical.Enter();
-		m_Game_str->SetLabel(wxString::Format(wxT(" Game : %s"), m_selectedGame.c_str()));
+		//m_Game_str->SetLabel(wxString::Format(wxT(" Game : %s"), m_selectedGame.c_str()));
+		//Note By Daco : i'd hate to make another variable... (they take up space :( )
+		std::string temp = " Game : " + m_selectedGame;
+		m_Game_str->SetLabel(wxString::FromAscii( temp.c_str() ));
 		m_critical.Leave();
 	}
 }
@@ -544,7 +549,7 @@ void GameListPopup::OnButtons(wxCommandEvent& event)
 	switch (event.GetId())
 	{
 	case wxID_OK:
-		if (m_GameList->GetSelection() != wxNOT_FOUND)
+		if (m_GameList->GetSelection()-1 != wxNOT_FOUND)
 			m_netParent->ChangeSelectedGame(std::string(m_GameList_str[m_GameList->GetSelection()].mb_str()));
 		Destroy();
 		break;
diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp
index 1c969b606e..acc14d8923 100644
--- a/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp
+++ b/Source/Plugins/Plugin_DSP_LLE/Src/DSPDebugInterface.cpp
@@ -87,7 +87,7 @@ void DSPDebugInterface::setBreakpoint(unsigned int address)
 	int real_addr = DSPSymbols::Line2Addr(address);
 	if (real_addr >= 0) {
 		if (dsp_breakpoints.Add(real_addr))
-			;
+		{}
 	}
 }
 
@@ -96,7 +96,7 @@ void DSPDebugInterface::clearBreakpoint(unsigned int address)
 	int real_addr = DSPSymbols::Line2Addr(address);
 	if (real_addr >= 0) {
 		if (dsp_breakpoints.Remove(real_addr))
-			;
+		{}
 	}
 }