From 6d5b7910a4b2738c3351871a29ca3dcfc603785a Mon Sep 17 00:00:00 2001 From: Josh Allen Date: Sat, 28 Aug 2004 13:41:22 +0000 Subject: [PATCH] Removed overlooked cout statements and headers. Also added code to deal with the scenario of the server not starting. --- stepmania/src/NetworkSyncManager.cpp | 12 +++++++++--- stepmania/src/NetworkSyncServer.cpp | 14 +++++--------- stepmania/src/NetworkSyncServer.h | 7 +------ 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/stepmania/src/NetworkSyncManager.cpp b/stepmania/src/NetworkSyncManager.cpp index 05f2b41d78..2901458fc5 100644 --- a/stepmania/src/NetworkSyncManager.cpp +++ b/stepmania/src/NetworkSyncManager.cpp @@ -170,9 +170,15 @@ void NetworkSyncManager::StartUp() { CString ServerIP; - if( isLanServer ) { - LANserver->ServerStart(); - } + if( isLanServer ) + if (LANserver->ServerStart() == false) { + //If the server happens to not start when told, + //Print to log and release the memory where the + //server was held. + isLanServer = false; + LOG->Warn("Server failed to start."); + delete LANserver; + } if( GetCommandlineArgument( "netip", &ServerIP ) ) PostStartUp(ServerIP); diff --git a/stepmania/src/NetworkSyncServer.cpp b/stepmania/src/NetworkSyncServer.cpp index d3c39e605d..c6ddbf411a 100644 --- a/stepmania/src/NetworkSyncServer.cpp +++ b/stepmania/src/NetworkSyncServer.cpp @@ -23,15 +23,18 @@ StepManiaLanServer::~StepManiaLanServer() { ServerStop(); } -void StepManiaLanServer::ServerStart() { +bool StepManiaLanServer::ServerStart() { server.blocking = 0; /* Turn off blocking */ if (server.create()) if (server.bind(8765)) if (server.listen()) { stop = false; statsTime = time(NULL); + return true; } + //Hopefully we will not get here. If we did, something went wrong above. + return false; } void StepManiaLanServer::ServerStop() { @@ -175,11 +178,6 @@ void GameClient::StartRequest(PacketFunctions &Packet) { gameInfo.artist = Packet.ReadNT(); gameInfo.course = Packet.ReadNT(); - cout << gameInfo.title << endl; - cout << gameInfo.subtitle << endl; - cout << gameInfo.artist << endl; - cout << gameInfo.course << endl; - Player[0].score = 0; Player[0].combo = 0; Player[0].projgrade = 0; @@ -371,10 +369,8 @@ void StepManiaLanServer::NewClientCheck() { in that client socket.*/ int CurrentEmptyClient = FindEmptyClient(); if (CurrentEmptyClient > -1) - if (server.accept(Client[CurrentEmptyClient].clientSocket) == 1) { + if (server.accept(Client[CurrentEmptyClient].clientSocket) == 1) Client[CurrentEmptyClient].Used = 1; - cout << "Added client to " << CurrentEmptyClient << endl; - } } diff --git a/stepmania/src/NetworkSyncServer.h b/stepmania/src/NetworkSyncServer.h index 7124b5d125..cd2e897821 100644 --- a/stepmania/src/NetworkSyncServer.h +++ b/stepmania/src/NetworkSyncServer.h @@ -5,13 +5,8 @@ #include "ezsockets.h" #include "NetworkSyncManager.h" -#include -#include - #include -#include - #include "StdString.h" using namespace std; @@ -73,7 +68,7 @@ class GameClient { class StepManiaLanServer { public: - void ServerStart(); + bool ServerStart(); void ServerStop(); void ServerUpdate(); StepManiaLanServer();