Networking now tells user if connection was successful or unsuccessful.

This commit is contained in:
Charles Lohr
2004-04-29 01:03:28 +00:00
parent efc61b33d6
commit 858b3fa587
3 changed files with 38 additions and 1 deletions
+30
View File
@@ -21,6 +21,7 @@
#include "RageUtil.h"
#include "ThemeManager.h"
#include "ScreenSelectMusic.h"
#include "Screen.h"
#include "PlayerNumber.h"
#include "GameConstantsAndTypes.h"
#include "SongOptions.h"
@@ -40,6 +41,7 @@ NetworkSyncManager::NetworkSyncManager()
m_ServerVersion = 0;
useSMserver = false;
m_startupStatus = 0; //By default, connection not tried.
StartUp();
}
@@ -55,10 +57,12 @@ NetworkSyncManager::~NetworkSyncManager ()
void NetworkSyncManager::StartUp()
{
CString ServerIP;
if( GetCommandlineArgument( "netip", &ServerIP ) )
{
if( !Connect(ServerIP.c_str(),8765) )
{
m_startupStatus = 2;
LOG->Warn( "Network Sync Manager failed to connect" );
return;
}
@@ -68,6 +72,7 @@ void NetworkSyncManager::StartUp()
{
if( !Listen(8765) )
{
m_startupStatus = 2;
LOG->Warn( "Listen() failed");
return;
}
@@ -78,6 +83,8 @@ void NetworkSyncManager::StartUp()
useSMserver = true;
m_startupStatus = 1; //Connection attepmpt sucessful
int ClientCommand=3;
NetPlayerClient->send((char*) &ClientCommand, 4);
@@ -248,6 +255,9 @@ void NetworkSyncManager::StartRequest()
//SMOnline server.
void NetworkSyncManager::SendSongs()
{
if (!useSMserver)
return ;
vector <Song *> LogSongs;
LogSongs = SONGMAN->GetAllSongs();
unsigned i,j;
@@ -324,7 +334,27 @@ void ArgStartCourse(CString CourseName)
GAMESTATE->BeginStage();
}
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
+5 -1
View File
@@ -33,6 +33,8 @@ public:
bool Connect(const CString& addy, unsigned short port); // Connect to SM Server
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
private:
@@ -42,7 +44,9 @@ private:
int m_step;
int m_score;
int m_combo;
int m_startupStatus; //Used to see if attempt was sucessful or not.
bool useSMserver;
EzSockets *NetPlayerClient;
+3
View File
@@ -921,6 +921,9 @@ static void ProcessArgsSecond()
//use it a lot.
if( GetCommandlineArgument( "course", & Argument ) )
ArgStartCourse(Argument);
if( GetCommandlineArgument( "netip" ) )
NSMAN->DisplayStartupStatus(); //If we're using networking show what happend
}
int main(int argc, char* argv[])