Networking now tells user if connection was successful or unsuccessful.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "ScreenSelectMusic.h"
|
#include "ScreenSelectMusic.h"
|
||||||
|
#include "Screen.h"
|
||||||
#include "PlayerNumber.h"
|
#include "PlayerNumber.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
#include "SongOptions.h"
|
#include "SongOptions.h"
|
||||||
@@ -40,6 +41,7 @@ NetworkSyncManager::NetworkSyncManager()
|
|||||||
m_ServerVersion = 0;
|
m_ServerVersion = 0;
|
||||||
|
|
||||||
useSMserver = false;
|
useSMserver = false;
|
||||||
|
m_startupStatus = 0; //By default, connection not tried.
|
||||||
|
|
||||||
StartUp();
|
StartUp();
|
||||||
}
|
}
|
||||||
@@ -55,10 +57,12 @@ NetworkSyncManager::~NetworkSyncManager ()
|
|||||||
void NetworkSyncManager::StartUp()
|
void NetworkSyncManager::StartUp()
|
||||||
{
|
{
|
||||||
CString ServerIP;
|
CString ServerIP;
|
||||||
|
|
||||||
if( GetCommandlineArgument( "netip", &ServerIP ) )
|
if( GetCommandlineArgument( "netip", &ServerIP ) )
|
||||||
{
|
{
|
||||||
if( !Connect(ServerIP.c_str(),8765) )
|
if( !Connect(ServerIP.c_str(),8765) )
|
||||||
{
|
{
|
||||||
|
m_startupStatus = 2;
|
||||||
LOG->Warn( "Network Sync Manager failed to connect" );
|
LOG->Warn( "Network Sync Manager failed to connect" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -68,6 +72,7 @@ void NetworkSyncManager::StartUp()
|
|||||||
{
|
{
|
||||||
if( !Listen(8765) )
|
if( !Listen(8765) )
|
||||||
{
|
{
|
||||||
|
m_startupStatus = 2;
|
||||||
LOG->Warn( "Listen() failed");
|
LOG->Warn( "Listen() failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -78,6 +83,8 @@ void NetworkSyncManager::StartUp()
|
|||||||
|
|
||||||
useSMserver = true;
|
useSMserver = true;
|
||||||
|
|
||||||
|
m_startupStatus = 1; //Connection attepmpt sucessful
|
||||||
|
|
||||||
int ClientCommand=3;
|
int ClientCommand=3;
|
||||||
NetPlayerClient->send((char*) &ClientCommand, 4);
|
NetPlayerClient->send((char*) &ClientCommand, 4);
|
||||||
|
|
||||||
@@ -248,6 +255,9 @@ void NetworkSyncManager::StartRequest()
|
|||||||
//SMOnline server.
|
//SMOnline server.
|
||||||
void NetworkSyncManager::SendSongs()
|
void NetworkSyncManager::SendSongs()
|
||||||
{
|
{
|
||||||
|
if (!useSMserver)
|
||||||
|
return ;
|
||||||
|
|
||||||
vector <Song *> LogSongs;
|
vector <Song *> LogSongs;
|
||||||
LogSongs = SONGMAN->GetAllSongs();
|
LogSongs = SONGMAN->GetAllSongs();
|
||||||
unsigned i,j;
|
unsigned i,j;
|
||||||
@@ -325,6 +335,26 @@ void ArgStartCourse(CString CourseName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetworkSyncManager::DisplayStartupStatus()
|
||||||
|
{
|
||||||
|
CString sMessage("");
|
||||||
|
|
||||||
|
switch (m_startupStatus)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
//Networking wasn't attepmpted
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sMessage = "Connect to server successful.";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sMessage = "Connection failed.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// SCREENMAN->RefreshCreditsMessages();
|
||||||
|
SCREENMAN->SystemMessage(sMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//Global and accessable from anywhere
|
//Global and accessable from anywhere
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public:
|
|||||||
bool Connect(const CString& addy, unsigned short port); // Connect to SM Server
|
bool Connect(const CString& addy, unsigned short port); // Connect to SM Server
|
||||||
void SendSongs(); //Send song list to server (And exit)
|
void SendSongs(); //Send song list to server (And exit)
|
||||||
|
|
||||||
|
void DisplayStartupStatus(); //Used to note user if connect attempt was sucessful or not.
|
||||||
|
|
||||||
int m_playerLife[NUM_PLAYERS]; //Life
|
int m_playerLife[NUM_PLAYERS]; //Life
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -43,6 +45,8 @@ private:
|
|||||||
int m_score;
|
int m_score;
|
||||||
int m_combo;
|
int m_combo;
|
||||||
|
|
||||||
|
int m_startupStatus; //Used to see if attempt was sucessful or not.
|
||||||
|
|
||||||
bool useSMserver;
|
bool useSMserver;
|
||||||
|
|
||||||
EzSockets *NetPlayerClient;
|
EzSockets *NetPlayerClient;
|
||||||
|
|||||||
@@ -921,6 +921,9 @@ static void ProcessArgsSecond()
|
|||||||
//use it a lot.
|
//use it a lot.
|
||||||
if( GetCommandlineArgument( "course", & Argument ) )
|
if( GetCommandlineArgument( "course", & Argument ) )
|
||||||
ArgStartCourse(Argument);
|
ArgStartCourse(Argument);
|
||||||
|
|
||||||
|
if( GetCommandlineArgument( "netip" ) )
|
||||||
|
NSMAN->DisplayStartupStatus(); //If we're using networking show what happend
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
|||||||
Reference in New Issue
Block a user