Removed overlooked cout statements and headers. Also added code to deal with the scenario of the server not starting.
This commit is contained in:
@@ -170,9 +170,15 @@ 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 ) )
|
||||||
PostStartUp(ServerIP);
|
PostStartUp(ServerIP);
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user