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
+9 -3
View File
@@ -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);
+5 -9
View File
@@ -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;
}
}
+1 -6
View File
@@ -5,13 +5,8 @@
#include "ezsockets.h"
#include "NetworkSyncManager.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
#include "StdString.h"
using namespace std;
@@ -73,7 +68,7 @@ class GameClient {
class StepManiaLanServer {
public:
void ServerStart();
bool ServerStart();
void ServerStop();
void ServerUpdate();
StepManiaLanServer();