Removed overlooked cout statements and headers. Also added code to deal with the scenario of the server not starting.

This commit is contained in:
Josh Allen
2004-08-28 13:41:22 +00:00
parent 6a25c126ab
commit 6d5b7910a4
3 changed files with 15 additions and 18 deletions
+8 -2
View File
@@ -170,8 +170,14 @@ void NetworkSyncManager::StartUp()
{ {
CString ServerIP; CString ServerIP;
if( isLanServer ) { if( isLanServer )
LANserver->ServerStart(); 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 ) ) if( GetCommandlineArgument( "netip", &ServerIP ) )
+5 -9
View File
@@ -23,15 +23,18 @@ StepManiaLanServer::~StepManiaLanServer() {
ServerStop(); ServerStop();
} }
void StepManiaLanServer::ServerStart() { bool StepManiaLanServer::ServerStart() {
server.blocking = 0; /* Turn off blocking */ server.blocking = 0; /* Turn off blocking */
if (server.create()) if (server.create())
if (server.bind(8765)) if (server.bind(8765))
if (server.listen()) { if (server.listen()) {
stop = false; stop = false;
statsTime = time(NULL); statsTime = time(NULL);
return true;
} }
//Hopefully we will not get here. If we did, something went wrong above.
return false;
} }
void StepManiaLanServer::ServerStop() { void StepManiaLanServer::ServerStop() {
@@ -175,11 +178,6 @@ void GameClient::StartRequest(PacketFunctions &Packet) {
gameInfo.artist = Packet.ReadNT(); gameInfo.artist = Packet.ReadNT();
gameInfo.course = 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].score = 0;
Player[0].combo = 0; Player[0].combo = 0;
Player[0].projgrade = 0; Player[0].projgrade = 0;
@@ -371,10 +369,8 @@ void StepManiaLanServer::NewClientCheck() {
in that client socket.*/ in that client socket.*/
int CurrentEmptyClient = FindEmptyClient(); int CurrentEmptyClient = FindEmptyClient();
if (CurrentEmptyClient > -1) if (CurrentEmptyClient > -1)
if (server.accept(Client[CurrentEmptyClient].clientSocket) == 1) { if (server.accept(Client[CurrentEmptyClient].clientSocket) == 1)
Client[CurrentEmptyClient].Used = 1; Client[CurrentEmptyClient].Used = 1;
cout << "Added client to " << CurrentEmptyClient << endl;
}
} }
+1 -6
View File
@@ -5,13 +5,8 @@
#include "ezsockets.h" #include "ezsockets.h"
#include "NetworkSyncManager.h" #include "NetworkSyncManager.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h> #include <time.h>
#include <iostream>
#include "StdString.h" #include "StdString.h"
using namespace std; using namespace std;
@@ -73,7 +68,7 @@ class GameClient {
class StepManiaLanServer { class StepManiaLanServer {
public: public:
void ServerStart(); bool ServerStart();
void ServerStop(); void ServerStop();
void ServerUpdate(); void ServerUpdate();
StepManiaLanServer(); StepManiaLanServer();