add *.user, Win32, and x64 build dir to ignore list for DebuggerUICommon and Unit Tests

add *.aps to ignore list for DolphinWX dir
add eol-style native to 120 or so files

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3689 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
LPFaint99
2009-07-06 02:10:26 +00:00
parent 23f3e327e2
commit a41c1b2d0a
94 changed files with 24089 additions and 24089 deletions
+288 -288
View File
@@ -1,288 +1,288 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "NetWindow.h"
void ClientSide::OnClientData(unsigned char data)
{
unsigned char sent = 0;
u32 buffer_size;
size_t recv_size;
char *buffer = NULL;
switch (data)
{
case 0x10: // Player joined server
{
// Read GameFound
m_socket.Receive((char*)&sent, 1, recv_size);
// Read nickname
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
Event->AppendText(wxString::Format(wxT("*Player : %s is now connected to Host...\n"), buffer));
if (sent != 0x1F)
for (int i = 0; i < 4; i++)
Event->AppendText(_("WARNING : Game Not Found on Client Side!\n"));
m_numplayers++;
Event->SendEvent(HOST_NEWPLAYER);
break;
}
case 0x11: // Player left server
{
// Read Nickname
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
Event->AppendText(wxString::Format(wxT("*Player : %s left the game\n\n"), buffer));
m_numplayers--;
Event->SendEvent(HOST_PLAYERLEFT);
break;
}
case 0x15: // Ping Player
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
m_socket.Send((const char*)&buffer_size, 4);
break;
}
case 0x20: // IP request
{
//buffer_size = m_addr.size();
//m_socket.Send((const char*)&buffer_size, 4);
m_socket.Send((const char*)&data, 1);
m_socket.Send(m_addr.c_str(), m_addr.size() + 1);
break;
}
case 0x30: // Chat message received from server
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
if (recv_size > 1024)
{
//something wrong...
delete[] buffer;
return;
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x35: // ChangeGame message received
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
m_selectedgame = std::string(buffer);
Event->AppendText(wxString::Format(wxT("*Host changed Game to : %s\n"), buffer));
// Tell the server if the game's been found
m_socket.Send((const char*)&data, 1);
CheckGameFound();
Event->SendEvent(GUI_UPDATE);
break;
}
case 0x40: // Ready message received
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
if (recv_size > 1024)
{
delete[] buffer;
return;
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x50: // Everyone is Ready message received
{
// Load the game and start synching
m_netptr->LoadGame();
break;
}
case 0xA1: // Received pad data from host in versus mode
{
if (m_data_received)
wxThread::Sleep(10);
m_socket.Receive((char*)m_netvalues[0], 8, recv_size);
m_data_received = true;
#ifdef NET_DEBUG
char sent[64];
sprintf(sent, "Received Values: 0x%08x : 0x%08x \n", m_netvalues[0][0], m_netvalues[0][1]);
Event->AppendText(wxString::FromAscii(sent));
#endif
break;
}
}
delete[] buffer;
}
void ServerSide::OnServerData(int sock, unsigned char data)
{
size_t recv_size;
char *buffer = NULL;
unsigned char sent;
unsigned int four_bytes;
switch (data)
{
case 0x15: // Ping Request
{
m_client[sock].socket.Receive((char*)&four_bytes, 4, recv_size);
m_client[sock].socket.Send((const char*)&four_bytes, 4);
break;
}
case 0x20: // IP request response
{
buffer = new char[24];
// Read IP Address
m_client[sock].socket.Receive(buffer, 24, recv_size);
Event->AppendText(wxString::Format(wxT("> Your IP is : %s\n"), buffer));
break;
}
case 0x30: // Chat message
{
buffer = new char[1024];
m_client[sock].socket.Receive((char*)&four_bytes, 4, recv_size);
m_client[sock].socket.Receive((char*)buffer, four_bytes + 1, recv_size);
if (recv_size > 1024)
{
//something wrong...
delete[] buffer;
return;
}
sent = 0x30;
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
if (i == sock)
continue;
m_client[i].socket.Send((const char*)&sent, 1);
m_client[1].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(buffer, recv_size);
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x35: // Change game response received
{
// Receive isGameFound response (0x1F / 0x1A)
m_client[sock].socket.Receive((char*)&sent, 1, recv_size);
// If game is not found
if (sent != 0x1F)
{
sent = 0x30;
wxString error_str = wxString::Format(
wxT("WARNING : Player %s does Not have this Game !\n"), m_client[sock].nick.c_str());
four_bytes = (int)error_str.size();
for (int i=0; i < 2; i++)
Event->AppendText(error_str);
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
if (i == sock)
continue;
m_client[i].socket.Send((const char*)&sent, 1);
m_client[i].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(error_str.mb_str(), four_bytes + 1);
}
}
break;
}
case 0x40: // Ready message received
{
std::string buffer_str;
m_client[sock].ready = !m_client[sock].ready;
if (m_client[sock].ready)
buffer_str = ">> "+m_client[sock].nick+" is now ready !\n";
else
buffer_str = ">> "+m_client[sock].nick+" is now Unready !\n";
four_bytes = (int)buffer_str.size();
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
m_client[i].socket.Send((const char*)&data, 1);
m_client[i].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(buffer_str.c_str(), four_bytes+1);
}
Event->AppendText(wxString::FromAscii(buffer_str.c_str()));
IsEveryoneReady();
break;
}
case 0xA1: // Received pad data from a client
{
if (m_data_received)
wxThread::Sleep(10);
m_client[sock].socket.Receive((char*)m_netvalues[sock], 8, recv_size);
m_data_received = true;
#ifdef NET_DEBUG
char sent[64];
sprintf(sent, "Received Values: 0x%08x : 0x%08x \n", m_netvalues[sock][0], m_netvalues[sock][1]);
Event->AppendText(wxString::FromAscii(sent));
#endif
break;
}
}
delete[] buffer;
}
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "NetWindow.h"
void ClientSide::OnClientData(unsigned char data)
{
unsigned char sent = 0;
u32 buffer_size;
size_t recv_size;
char *buffer = NULL;
switch (data)
{
case 0x10: // Player joined server
{
// Read GameFound
m_socket.Receive((char*)&sent, 1, recv_size);
// Read nickname
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
Event->AppendText(wxString::Format(wxT("*Player : %s is now connected to Host...\n"), buffer));
if (sent != 0x1F)
for (int i = 0; i < 4; i++)
Event->AppendText(_("WARNING : Game Not Found on Client Side!\n"));
m_numplayers++;
Event->SendEvent(HOST_NEWPLAYER);
break;
}
case 0x11: // Player left server
{
// Read Nickname
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
Event->AppendText(wxString::Format(wxT("*Player : %s left the game\n\n"), buffer));
m_numplayers--;
Event->SendEvent(HOST_PLAYERLEFT);
break;
}
case 0x15: // Ping Player
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
m_socket.Send((const char*)&buffer_size, 4);
break;
}
case 0x20: // IP request
{
//buffer_size = m_addr.size();
//m_socket.Send((const char*)&buffer_size, 4);
m_socket.Send((const char*)&data, 1);
m_socket.Send(m_addr.c_str(), m_addr.size() + 1);
break;
}
case 0x30: // Chat message received from server
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
if (recv_size > 1024)
{
//something wrong...
delete[] buffer;
return;
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x35: // ChangeGame message received
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
m_selectedgame = std::string(buffer);
Event->AppendText(wxString::Format(wxT("*Host changed Game to : %s\n"), buffer));
// Tell the server if the game's been found
m_socket.Send((const char*)&data, 1);
CheckGameFound();
Event->SendEvent(GUI_UPDATE);
break;
}
case 0x40: // Ready message received
{
m_socket.Receive((char*)&buffer_size, 4, recv_size);
buffer = new char[buffer_size+1];
m_socket.Receive(buffer, buffer_size+1, recv_size);
if (recv_size > 1024)
{
delete[] buffer;
return;
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x50: // Everyone is Ready message received
{
// Load the game and start synching
m_netptr->LoadGame();
break;
}
case 0xA1: // Received pad data from host in versus mode
{
if (m_data_received)
wxThread::Sleep(10);
m_socket.Receive((char*)m_netvalues[0], 8, recv_size);
m_data_received = true;
#ifdef NET_DEBUG
char sent[64];
sprintf(sent, "Received Values: 0x%08x : 0x%08x \n", m_netvalues[0][0], m_netvalues[0][1]);
Event->AppendText(wxString::FromAscii(sent));
#endif
break;
}
}
delete[] buffer;
}
void ServerSide::OnServerData(int sock, unsigned char data)
{
size_t recv_size;
char *buffer = NULL;
unsigned char sent;
unsigned int four_bytes;
switch (data)
{
case 0x15: // Ping Request
{
m_client[sock].socket.Receive((char*)&four_bytes, 4, recv_size);
m_client[sock].socket.Send((const char*)&four_bytes, 4);
break;
}
case 0x20: // IP request response
{
buffer = new char[24];
// Read IP Address
m_client[sock].socket.Receive(buffer, 24, recv_size);
Event->AppendText(wxString::Format(wxT("> Your IP is : %s\n"), buffer));
break;
}
case 0x30: // Chat message
{
buffer = new char[1024];
m_client[sock].socket.Receive((char*)&four_bytes, 4, recv_size);
m_client[sock].socket.Receive((char*)buffer, four_bytes + 1, recv_size);
if (recv_size > 1024)
{
//something wrong...
delete[] buffer;
return;
}
sent = 0x30;
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
if (i == sock)
continue;
m_client[i].socket.Send((const char*)&sent, 1);
m_client[1].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(buffer, recv_size);
}
Event->AppendText(wxString::FromAscii(buffer));
break;
}
case 0x35: // Change game response received
{
// Receive isGameFound response (0x1F / 0x1A)
m_client[sock].socket.Receive((char*)&sent, 1, recv_size);
// If game is not found
if (sent != 0x1F)
{
sent = 0x30;
wxString error_str = wxString::Format(
wxT("WARNING : Player %s does Not have this Game !\n"), m_client[sock].nick.c_str());
four_bytes = (int)error_str.size();
for (int i=0; i < 2; i++)
Event->AppendText(error_str);
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
if (i == sock)
continue;
m_client[i].socket.Send((const char*)&sent, 1);
m_client[i].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(error_str.mb_str(), four_bytes + 1);
}
}
break;
}
case 0x40: // Ready message received
{
std::string buffer_str;
m_client[sock].ready = !m_client[sock].ready;
if (m_client[sock].ready)
buffer_str = ">> "+m_client[sock].nick+" is now ready !\n";
else
buffer_str = ">> "+m_client[sock].nick+" is now Unready !\n";
four_bytes = (int)buffer_str.size();
// Send to all
for (int i=0; i < m_numplayers ; i++)
{
m_client[i].socket.Send((const char*)&data, 1);
m_client[i].socket.Send((const char*)&four_bytes, 4);
m_client[i].socket.Send(buffer_str.c_str(), four_bytes+1);
}
Event->AppendText(wxString::FromAscii(buffer_str.c_str()));
IsEveryoneReady();
break;
}
case 0xA1: // Received pad data from a client
{
if (m_data_received)
wxThread::Sleep(10);
m_client[sock].socket.Receive((char*)m_netvalues[sock], 8, recv_size);
m_data_received = true;
#ifdef NET_DEBUG
char sent[64];
sprintf(sent, "Received Values: 0x%08x : 0x%08x \n", m_netvalues[sock][0], m_netvalues[sock][1]);
Event->AppendText(wxString::FromAscii(sent));
#endif
break;
}
}
delete[] buffer;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+317 -317
View File
@@ -1,317 +1,317 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _NETWINDOW_H_
#define _NETWINDOW_H_
#include <SFML/Network.hpp>
#include <string>
#include <wx/wx.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
#include <wx/notebook.h>
#include <wx/gbsizer.h>
#include <wx/listbox.h>
#include <wx/thread.h>
#include "Globals.h"
#include "BootManager.h"
#include "Common.h"
#include "Core.h"
#include "pluginspecs_pad.h"
#include "HW/SI.h"
#include "HW/SI_Device.h"
#include "HW/SI_DeviceGCController.h"
#include "Timer.h"
#ifdef _DEBUG
#define NET_DEBUG
#endif
// Use TCP instead of UDP to send pad data @ 60fps. Suitable and better for LAN netplay,
// Unrealistic for Internet netplay, unless you have an uberfast connexion (<10ms ping)
// #define USE_TCP
class NetPlay;
struct Netpads {
int nHi[128];
int nLow[128];
};
struct Clients {
std::string nick;
sf::SocketTCP socket;
unsigned short port;
sf::IPAddress address;
bool ready;
};
class NetEvent
{
public:
NetEvent(NetPlay* netptr) { m_netptr = netptr; }
~NetEvent() {};
void SendEvent(int EventType, std::string="NULL", int=NULL);
void AppendText(const wxString text);
private:
NetPlay *m_netptr;
};
class ServerSide : public wxThread
{
public:
ServerSide(NetPlay* netptr, sf::SocketTCP, sf::SocketUDP, int netmodel, std::string nick);
~ServerSide() {};
virtual void *Entry();
void Write(int socknb, const char *data, size_t size, long *ping=NULL);
void WriteUDP(int socknb, const char *data, size_t size);
bool isNewPadData(u32 *netValues, bool current, int client=0);
private:
bool SyncValues(unsigned char, sf::IPAddress);
bool RecvT(sf::SocketUDP Socket, char * Data, size_t Max, size_t& Recvd, float Time = 0);
char GetSocket(sf::SocketTCP Socket);
void OnServerData(int sock, unsigned char data);
void IsEveryoneReady();
NetPlay *m_netptr;
NetEvent *Event;
u32 m_netvalues[3][3];
bool m_data_received; // New Pad data received ?
unsigned char m_numplayers;
int m_netmodel;
std::string m_nick;
Clients m_client[3]; // Connected client objects
sf::SelectorTCP m_selector;
sf::SocketTCP m_socket; // Server 'listening' socket
sf::SocketUDP m_socketUDP;
wxCriticalSection m_CriticalSection;
};
class ClientSide : public wxThread
{
public:
ClientSide(NetPlay* netptr, sf::SocketTCP, sf::SocketUDP, std::string addr, std::string nick);
~ClientSide() {}
virtual void *Entry();
void Write(const char *data, size_t size, long *ping=NULL);
void WriteUDP(const char *data, size_t size);
bool isNewPadData(u32 *netValues, bool current, bool isVersus=true);
private:
bool SyncValues();
void CheckGameFound();
void OnClientData(unsigned char data);
bool RecvT(sf::SocketUDP Socket, char * Data, size_t Max, size_t& Recvd, float Time=0);
NetPlay *m_netptr;
NetEvent *Event;
u32 m_netvalues[3][3];
bool m_data_received; // New Pad data received ?
unsigned char m_numplayers;
int m_netmodel;
std::string m_nick;
std::string m_hostnick;
std::string m_selectedgame;
sf::SelectorTCP m_selector;
sf::SocketTCP m_socket; // Client I/O socket
sf::SocketUDP m_socketUDP;
unsigned short m_port;
std::string m_addr; // Contains the server addr
wxCriticalSection m_CriticalSection;
};
class NetPlay : public wxFrame
{
public:
NetPlay(wxWindow* parent, std::string GamePath = "", std::string GameName = "");
~NetPlay();
void UpdateNetWindow(bool update_infos, wxString=wxT("NULL"));
void AppendText(const wxString text) { m_Logging->AppendText(text); }
// Send and receive pads values
bool GetNetPads(u8 pad_nb, SPADStatus, u32 *netvalues);
void ChangeSelectedGame(std::string game);
void IsGameFound(unsigned char*, std::string);
std::string GetSelectedGame() { wxCriticalSectionLocker lock(m_critical); return m_selectedGame; }
void LoadGame();
protected:
// Protects our vars from being fuxored by threads
wxCriticalSection m_critical;
// this draws the GUI, ya rly
void DrawGUI();
void DrawNetWindow();
// event handlers
void OnGUIEvent(wxCommandEvent& event);
void OnDisconnect(wxCommandEvent& event);
void OnNetEvent(wxCommandEvent& event);
void OnQuit(wxCloseEvent& event);
void OnJoin(wxCommandEvent& event);
void OnHost(wxCommandEvent& event);
// Net play vars (used ingame)
int m_frame;
int m_lastframe;
Common::Timer m_timer;
int m_loopframe;
int m_frameDelay;
bool m_data_received;// True if first frame data received
// Basic vars
std::string m_paths; // Game paths list
std::string m_games; // Game names list
std::string m_selectedGame;// Selected game's string
std::string m_hostaddr; // Used with OnGetIP to cache it
bool m_ready, m_clients_ready;
std::string m_nick;
int m_NetModel; // Using P2P model (0) or Server model (1)
int m_isHosting; // 0 = false ; 1 = true ; 2 = Not set
unsigned char m_numClients; // starting from 0, 4 players max thus 3 clients
std::string m_address; // The address entered into connection box
unsigned short m_port;
Netpads m_pads[4]; // this struct is used to save synced pad values
IniFile ConfigIni;
// Sockets objects
ServerSide *m_sock_server;
ClientSide *m_sock_client;
// -----------
// GUI objects
// -----------
wxNotebook *m_Notebook;
wxPanel *m_Tab_Connect;
wxPanel *m_Tab_Host;
wxStaticText *m_SetNick_text;
wxTextCtrl *m_SetNick;
wxChoice *m_NetMode;
// Host tab :
wxArrayString m_GameList_str;
wxStaticText *m_GameList_text;
wxListBox *m_GameList;
wxStaticText *m_SetPort_text;
wxTextCtrl *m_SetPort;
wxButton *m_HostGame;
// Connect tab :
wxTextCtrl *m_ConAddr;
wxStaticText *m_ConAddr_text;
wxButton *m_JoinGame;
wxCheckBox *m_UseRandomPort;
// Connection window
wxButton *m_Game_str;
wxTextCtrl *m_Logging;
wxTextCtrl *m_Chat;
wxButton *m_Chat_ok;
// Right part
wxButton *m_wtfismyip;
wxButton *m_ChangeGame;
// Left Part
wxButton *m_Disconnect;
wxStaticText *m_ConInfo_text;
wxButton *m_GetPing;
wxCheckBox *m_Ready;
wxCheckBox *m_RecordGame;
// wxWidgets event table
DECLARE_EVENT_TABLE()
};
class GameListPopup : public wxDialog
{
public:
GameListPopup(NetPlay *net_ptr, wxArrayString GameNames);
~GameListPopup() {}
protected:
void OnButtons(wxCommandEvent& event);
wxArrayString m_GameList_str;
NetPlay* m_netParent;
wxListBox *m_GameList;
wxButton *m_Accept;
wxButton *m_Cancel;
DECLARE_EVENT_TABLE()
};
enum
{
ID_NOTEBOOK,
ID_TAB_HOST,
ID_TAB_CONN,
ID_BUTTON_HOST,
ID_BUTTON_JOIN,
ID_NETMODE,
ID_GAMELIST,
ID_LOGGING_TXT,
ID_CHAT,
ID_SETNICK,
ID_SETPORT,
ID_CONNADDR,
ID_CONNINFO_TXT,
ID_USE_RANDOMPORT,
ID_BUTTON_GETPING,
ID_BUTTON_GETIP,
ID_CHANGEGAME,
ID_BUTTON_QUIT,
ID_BUTTON_CHAT,
ID_READY,
ID_RECORD,
ID_SOCKET,
ID_SERVER,
HOST_FULL = 200, // ...
HOST_ERROR, // Sent on socket error
HOST_DISCONNECTED,
HOST_NEWPLAYER,
HOST_PLAYERLEFT,
CLIENTS_READY,
CLIENTS_NOTREADY,
GUI_UPDATE, // Refresh the shown selectedgame on GUI
ADD_TEXT, // Add text to m_Logging (string)
ADD_INFO, // Sent when updating net infos (string)
NET_EVENT
};
#endif // _NETWINDOW_H_
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _NETWINDOW_H_
#define _NETWINDOW_H_
#include <SFML/Network.hpp>
#include <string>
#include <wx/wx.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
#include <wx/notebook.h>
#include <wx/gbsizer.h>
#include <wx/listbox.h>
#include <wx/thread.h>
#include "Globals.h"
#include "BootManager.h"
#include "Common.h"
#include "Core.h"
#include "pluginspecs_pad.h"
#include "HW/SI.h"
#include "HW/SI_Device.h"
#include "HW/SI_DeviceGCController.h"
#include "Timer.h"
#ifdef _DEBUG
#define NET_DEBUG
#endif
// Use TCP instead of UDP to send pad data @ 60fps. Suitable and better for LAN netplay,
// Unrealistic for Internet netplay, unless you have an uberfast connexion (<10ms ping)
// #define USE_TCP
class NetPlay;
struct Netpads {
int nHi[128];
int nLow[128];
};
struct Clients {
std::string nick;
sf::SocketTCP socket;
unsigned short port;
sf::IPAddress address;
bool ready;
};
class NetEvent
{
public:
NetEvent(NetPlay* netptr) { m_netptr = netptr; }
~NetEvent() {};
void SendEvent(int EventType, std::string="NULL", int=NULL);
void AppendText(const wxString text);
private:
NetPlay *m_netptr;
};
class ServerSide : public wxThread
{
public:
ServerSide(NetPlay* netptr, sf::SocketTCP, sf::SocketUDP, int netmodel, std::string nick);
~ServerSide() {};
virtual void *Entry();
void Write(int socknb, const char *data, size_t size, long *ping=NULL);
void WriteUDP(int socknb, const char *data, size_t size);
bool isNewPadData(u32 *netValues, bool current, int client=0);
private:
bool SyncValues(unsigned char, sf::IPAddress);
bool RecvT(sf::SocketUDP Socket, char * Data, size_t Max, size_t& Recvd, float Time = 0);
char GetSocket(sf::SocketTCP Socket);
void OnServerData(int sock, unsigned char data);
void IsEveryoneReady();
NetPlay *m_netptr;
NetEvent *Event;
u32 m_netvalues[3][3];
bool m_data_received; // New Pad data received ?
unsigned char m_numplayers;
int m_netmodel;
std::string m_nick;
Clients m_client[3]; // Connected client objects
sf::SelectorTCP m_selector;
sf::SocketTCP m_socket; // Server 'listening' socket
sf::SocketUDP m_socketUDP;
wxCriticalSection m_CriticalSection;
};
class ClientSide : public wxThread
{
public:
ClientSide(NetPlay* netptr, sf::SocketTCP, sf::SocketUDP, std::string addr, std::string nick);
~ClientSide() {}
virtual void *Entry();
void Write(const char *data, size_t size, long *ping=NULL);
void WriteUDP(const char *data, size_t size);
bool isNewPadData(u32 *netValues, bool current, bool isVersus=true);
private:
bool SyncValues();
void CheckGameFound();
void OnClientData(unsigned char data);
bool RecvT(sf::SocketUDP Socket, char * Data, size_t Max, size_t& Recvd, float Time=0);
NetPlay *m_netptr;
NetEvent *Event;
u32 m_netvalues[3][3];
bool m_data_received; // New Pad data received ?
unsigned char m_numplayers;
int m_netmodel;
std::string m_nick;
std::string m_hostnick;
std::string m_selectedgame;
sf::SelectorTCP m_selector;
sf::SocketTCP m_socket; // Client I/O socket
sf::SocketUDP m_socketUDP;
unsigned short m_port;
std::string m_addr; // Contains the server addr
wxCriticalSection m_CriticalSection;
};
class NetPlay : public wxFrame
{
public:
NetPlay(wxWindow* parent, std::string GamePath = "", std::string GameName = "");
~NetPlay();
void UpdateNetWindow(bool update_infos, wxString=wxT("NULL"));
void AppendText(const wxString text) { m_Logging->AppendText(text); }
// Send and receive pads values
bool GetNetPads(u8 pad_nb, SPADStatus, u32 *netvalues);
void ChangeSelectedGame(std::string game);
void IsGameFound(unsigned char*, std::string);
std::string GetSelectedGame() { wxCriticalSectionLocker lock(m_critical); return m_selectedGame; }
void LoadGame();
protected:
// Protects our vars from being fuxored by threads
wxCriticalSection m_critical;
// this draws the GUI, ya rly
void DrawGUI();
void DrawNetWindow();
// event handlers
void OnGUIEvent(wxCommandEvent& event);
void OnDisconnect(wxCommandEvent& event);
void OnNetEvent(wxCommandEvent& event);
void OnQuit(wxCloseEvent& event);
void OnJoin(wxCommandEvent& event);
void OnHost(wxCommandEvent& event);
// Net play vars (used ingame)
int m_frame;
int m_lastframe;
Common::Timer m_timer;
int m_loopframe;
int m_frameDelay;
bool m_data_received;// True if first frame data received
// Basic vars
std::string m_paths; // Game paths list
std::string m_games; // Game names list
std::string m_selectedGame;// Selected game's string
std::string m_hostaddr; // Used with OnGetIP to cache it
bool m_ready, m_clients_ready;
std::string m_nick;
int m_NetModel; // Using P2P model (0) or Server model (1)
int m_isHosting; // 0 = false ; 1 = true ; 2 = Not set
unsigned char m_numClients; // starting from 0, 4 players max thus 3 clients
std::string m_address; // The address entered into connection box
unsigned short m_port;
Netpads m_pads[4]; // this struct is used to save synced pad values
IniFile ConfigIni;
// Sockets objects
ServerSide *m_sock_server;
ClientSide *m_sock_client;
// -----------
// GUI objects
// -----------
wxNotebook *m_Notebook;
wxPanel *m_Tab_Connect;
wxPanel *m_Tab_Host;
wxStaticText *m_SetNick_text;
wxTextCtrl *m_SetNick;
wxChoice *m_NetMode;
// Host tab :
wxArrayString m_GameList_str;
wxStaticText *m_GameList_text;
wxListBox *m_GameList;
wxStaticText *m_SetPort_text;
wxTextCtrl *m_SetPort;
wxButton *m_HostGame;
// Connect tab :
wxTextCtrl *m_ConAddr;
wxStaticText *m_ConAddr_text;
wxButton *m_JoinGame;
wxCheckBox *m_UseRandomPort;
// Connection window
wxButton *m_Game_str;
wxTextCtrl *m_Logging;
wxTextCtrl *m_Chat;
wxButton *m_Chat_ok;
// Right part
wxButton *m_wtfismyip;
wxButton *m_ChangeGame;
// Left Part
wxButton *m_Disconnect;
wxStaticText *m_ConInfo_text;
wxButton *m_GetPing;
wxCheckBox *m_Ready;
wxCheckBox *m_RecordGame;
// wxWidgets event table
DECLARE_EVENT_TABLE()
};
class GameListPopup : public wxDialog
{
public:
GameListPopup(NetPlay *net_ptr, wxArrayString GameNames);
~GameListPopup() {}
protected:
void OnButtons(wxCommandEvent& event);
wxArrayString m_GameList_str;
NetPlay* m_netParent;
wxListBox *m_GameList;
wxButton *m_Accept;
wxButton *m_Cancel;
DECLARE_EVENT_TABLE()
};
enum
{
ID_NOTEBOOK,
ID_TAB_HOST,
ID_TAB_CONN,
ID_BUTTON_HOST,
ID_BUTTON_JOIN,
ID_NETMODE,
ID_GAMELIST,
ID_LOGGING_TXT,
ID_CHAT,
ID_SETNICK,
ID_SETPORT,
ID_CONNADDR,
ID_CONNINFO_TXT,
ID_USE_RANDOMPORT,
ID_BUTTON_GETPING,
ID_BUTTON_GETIP,
ID_CHANGEGAME,
ID_BUTTON_QUIT,
ID_BUTTON_CHAT,
ID_READY,
ID_RECORD,
ID_SOCKET,
ID_SERVER,
HOST_FULL = 200, // ...
HOST_ERROR, // Sent on socket error
HOST_DISCONNECTED,
HOST_NEWPLAYER,
HOST_PLAYERLEFT,
CLIENTS_READY,
CLIENTS_NOTREADY,
GUI_UPDATE, // Refresh the shown selectedgame on GUI
ADD_TEXT, // Add text to m_Logging (string)
ADD_INFO, // Sent when updating net infos (string)
NET_EVENT
};
#endif // _NETWINDOW_H_
+126 -126
View File
@@ -1,127 +1,127 @@
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __SUMMARIZE_H__
#define __SUMMARIZE_H__
std::string Summarize_Plug()
{
return StringFromFormat(
"Plugin Information\n\n"
"Default GFX Plugin: %s\n"
"Default DSP Plugin: %s\n"
"Default PAD Plugin: %s\n"
"Default WiiMote Plugin: %s\n\n"
"Current GFX Plugin: %s\n"
"Current DSP Plugin: %s\n"
"Current PAD Plugin[0]: %s\n"
"Current PAD Plugin[1]: %s\n"
"Current PAD Plugin[2]: %s\n"
"Current PAD Plugin[3]: %s\n"
"Current WiiMote Plugin[0]: %s\n",
SConfig::GetInstance().m_DefaultGFXPlugin.c_str(),
SConfig::GetInstance().m_DefaultDSPPlugin.c_str(),
SConfig::GetInstance().m_DefaultPADPlugin.c_str(),
SConfig::GetInstance().m_DefaultWiiMotePlugin.c_str(),
Core::GetStartupParameter().m_strVideoPlugin.c_str(),
Core::GetStartupParameter().m_strDSPPlugin.c_str(),
Core::GetStartupParameter().m_strPadPlugin[0].c_str(),
Core::GetStartupParameter().m_strPadPlugin[1].c_str(),
Core::GetStartupParameter().m_strPadPlugin[2].c_str(),
Core::GetStartupParameter().m_strPadPlugin[3].c_str(),
Core::GetStartupParameter().m_strWiimotePlugin[0].c_str()
);
}
std::string Summarize_Settings()
{
return StringFromFormat(
"Dolphin Settings\n\n"
"Always HLE Bios: %s\n"
"Use Dynarec: %s\n"
"Use Dual Core: %s\n"
"DSP Thread: %s\n"
"Skip Idle: %s\n"
"Lock Threads: %s\n"
"Use Dual Core: %s\n"
"Default GCM: %s\n"
"DVD Root: %s\n"
"Optimize Quantizers: %s\n"
"Enable Cheats: %s\n"
"Selected Language: %d\n"
"Memcard A: %s\n"
"Memcard B: %s\n"
"Slot A: %d\n"
"Slot B: %d\n"
"Serial Port 1: %d\n"
"Run Compare Server: %s\n"
"Run Compare Client: %s\n"
"TLB Hack: %s\n"
"Frame Limit: %d\n"
"[Wii]Widescreen: %s\n"
"[Wii]Progressive Scan: %s\n",
Core::GetStartupParameter().bHLEBios?"True":"False",
Core::GetStartupParameter().bUseJIT?"True":"False",
Core::GetStartupParameter().bUseDualCore?"True":"False",
Core::GetStartupParameter().bDSPThread?"True":"False",
Core::GetStartupParameter().bSkipIdle?"True":"False",
Core::GetStartupParameter().bLockThreads?"True":"False",
Core::GetStartupParameter().bUseDualCore?"True":"False",
Core::GetStartupParameter().m_strDefaultGCM.c_str(),
Core::GetStartupParameter().m_strDVDRoot.c_str(),
Core::GetStartupParameter().bOptimizeQuantizers?"True":"False",
Core::GetStartupParameter().bEnableCheats?"True":"False",
Core::GetStartupParameter().SelectedLanguage, //FIXME show language based on index
SConfig::GetInstance().m_strMemoryCardA.c_str(),
SConfig::GetInstance().m_strMemoryCardB.c_str(),
SConfig::GetInstance().m_EXIDevice[0], //FIXME
SConfig::GetInstance().m_EXIDevice[1], //FIXME
SConfig::GetInstance().m_EXIDevice[2], //FIXME
Core::GetStartupParameter().bRunCompareServer?"True":"False",
Core::GetStartupParameter().bRunCompareClient?"True":"False",
Core::GetStartupParameter().iTLBHack?"True":"False",
SConfig::GetInstance().m_Framelimit*5,
Core::GetStartupParameter().bWidescreen?"True":"False",
Core::GetStartupParameter().bProgressiveScan?"True":"False"
);
}
std::string Summarize_CPU()
{
return StringFromFormat(
"Processor Information: \n%s\n",
cpu_info.Summarize().c_str()
);
}
std::string Summarize_Drives()
{
char ** drives = cdio_get_devices();
std::string drive;
for (int i = 0; drives[i] != NULL && i < 24; i++)
{
drive += StringFromFormat(
"CD/DVD Drive%d: %s\n",
i+1,
drives[i]
);
}
return drive;
}
// Copyright (C) 2003-2008 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef __SUMMARIZE_H__
#define __SUMMARIZE_H__
std::string Summarize_Plug()
{
return StringFromFormat(
"Plugin Information\n\n"
"Default GFX Plugin: %s\n"
"Default DSP Plugin: %s\n"
"Default PAD Plugin: %s\n"
"Default WiiMote Plugin: %s\n\n"
"Current GFX Plugin: %s\n"
"Current DSP Plugin: %s\n"
"Current PAD Plugin[0]: %s\n"
"Current PAD Plugin[1]: %s\n"
"Current PAD Plugin[2]: %s\n"
"Current PAD Plugin[3]: %s\n"
"Current WiiMote Plugin[0]: %s\n",
SConfig::GetInstance().m_DefaultGFXPlugin.c_str(),
SConfig::GetInstance().m_DefaultDSPPlugin.c_str(),
SConfig::GetInstance().m_DefaultPADPlugin.c_str(),
SConfig::GetInstance().m_DefaultWiiMotePlugin.c_str(),
Core::GetStartupParameter().m_strVideoPlugin.c_str(),
Core::GetStartupParameter().m_strDSPPlugin.c_str(),
Core::GetStartupParameter().m_strPadPlugin[0].c_str(),
Core::GetStartupParameter().m_strPadPlugin[1].c_str(),
Core::GetStartupParameter().m_strPadPlugin[2].c_str(),
Core::GetStartupParameter().m_strPadPlugin[3].c_str(),
Core::GetStartupParameter().m_strWiimotePlugin[0].c_str()
);
}
std::string Summarize_Settings()
{
return StringFromFormat(
"Dolphin Settings\n\n"
"Always HLE Bios: %s\n"
"Use Dynarec: %s\n"
"Use Dual Core: %s\n"
"DSP Thread: %s\n"
"Skip Idle: %s\n"
"Lock Threads: %s\n"
"Use Dual Core: %s\n"
"Default GCM: %s\n"
"DVD Root: %s\n"
"Optimize Quantizers: %s\n"
"Enable Cheats: %s\n"
"Selected Language: %d\n"
"Memcard A: %s\n"
"Memcard B: %s\n"
"Slot A: %d\n"
"Slot B: %d\n"
"Serial Port 1: %d\n"
"Run Compare Server: %s\n"
"Run Compare Client: %s\n"
"TLB Hack: %s\n"
"Frame Limit: %d\n"
"[Wii]Widescreen: %s\n"
"[Wii]Progressive Scan: %s\n",
Core::GetStartupParameter().bHLEBios?"True":"False",
Core::GetStartupParameter().bUseJIT?"True":"False",
Core::GetStartupParameter().bUseDualCore?"True":"False",
Core::GetStartupParameter().bDSPThread?"True":"False",
Core::GetStartupParameter().bSkipIdle?"True":"False",
Core::GetStartupParameter().bLockThreads?"True":"False",
Core::GetStartupParameter().bUseDualCore?"True":"False",
Core::GetStartupParameter().m_strDefaultGCM.c_str(),
Core::GetStartupParameter().m_strDVDRoot.c_str(),
Core::GetStartupParameter().bOptimizeQuantizers?"True":"False",
Core::GetStartupParameter().bEnableCheats?"True":"False",
Core::GetStartupParameter().SelectedLanguage, //FIXME show language based on index
SConfig::GetInstance().m_strMemoryCardA.c_str(),
SConfig::GetInstance().m_strMemoryCardB.c_str(),
SConfig::GetInstance().m_EXIDevice[0], //FIXME
SConfig::GetInstance().m_EXIDevice[1], //FIXME
SConfig::GetInstance().m_EXIDevice[2], //FIXME
Core::GetStartupParameter().bRunCompareServer?"True":"False",
Core::GetStartupParameter().bRunCompareClient?"True":"False",
Core::GetStartupParameter().iTLBHack?"True":"False",
SConfig::GetInstance().m_Framelimit*5,
Core::GetStartupParameter().bWidescreen?"True":"False",
Core::GetStartupParameter().bProgressiveScan?"True":"False"
);
}
std::string Summarize_CPU()
{
return StringFromFormat(
"Processor Information: \n%s\n",
cpu_info.Summarize().c_str()
);
}
std::string Summarize_Drives()
{
char ** drives = cdio_get_devices();
std::string drive;
for (int i = 0; drives[i] != NULL && i < 24; i++)
{
drive += StringFromFormat(
"CD/DVD Drive%d: %s\n",
i+1,
drives[i]
);
}
return drive;
}
#endif //__SUMMARIZE_H__