mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 22:21:18 +02:00
added client socket accept info to debug log as well as some change detection
This commit is contained in:
@@ -49,6 +49,7 @@ struct FormatString {
|
|||||||
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver):
|
MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, bool openNetworkSlots,bool parentMenuIsMasterserver):
|
||||||
MenuState(program, mainMenu, "new-game")
|
MenuState(program, mainMenu, "new-game")
|
||||||
{
|
{
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
NetworkManager &networkManager= NetworkManager::getInstance();
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
@@ -545,8 +546,11 @@ void MenuStateCustomGame::update()
|
|||||||
{
|
{
|
||||||
if(switchSetupRequests[i]!=NULL)
|
if(switchSetupRequests[i]!=NULL)
|
||||||
{
|
{
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork)
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork)
|
||||||
{
|
{
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//printf("switchSetupRequests[i]->getSelectedFactionName()=%s\n",switchSetupRequests[i]->getSelectedFactionName().c_str());
|
//printf("switchSetupRequests[i]->getSelectedFactionName()=%s\n",switchSetupRequests[i]->getSelectedFactionName().c_str());
|
||||||
//printf("switchSetupRequests[i]->getToTeam()=%d\n",switchSetupRequests[i]->getToTeam());
|
//printf("switchSetupRequests[i]->getToTeam()=%d\n",switchSetupRequests[i]->getToTeam());
|
||||||
|
|
||||||
@@ -602,6 +606,8 @@ void MenuStateCustomGame::update()
|
|||||||
|
|
||||||
if(connectionSlot->isConnected())
|
if(connectionSlot->isConnected())
|
||||||
{
|
{
|
||||||
|
//printf("FYI we have at least 1 client connected, slot = %d'\n",i);
|
||||||
|
|
||||||
haveAtLeastOneNetworkClientConnected = true;
|
haveAtLeastOneNetworkClientConnected = true;
|
||||||
currentConnectionCount++;
|
currentConnectionCount++;
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] B - ctNetwork\n",__FILE__,__FUNCTION__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] B - ctNetwork\n",__FILE__,__FUNCTION__);
|
||||||
@@ -827,11 +833,16 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
if(needToBroadcastServerSettings)
|
if(needToBroadcastServerSettings)
|
||||||
{
|
{
|
||||||
needToBroadcastServerSettings=false;
|
needToBroadcastServerSettings=false;
|
||||||
GameSettings gameSettings;
|
|
||||||
loadGameSettings(&gameSettings);
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setGameSettings(&gameSettings);
|
if(serverInterface->hasClientConnection() == true) {
|
||||||
serverInterface->broadcastGameSetup(&gameSettings);
|
//printf("Sending game settings broadcast since we have at least 1 client connected'\n");
|
||||||
|
|
||||||
|
GameSettings gameSettings;
|
||||||
|
loadGameSettings(&gameSettings);
|
||||||
|
|
||||||
|
serverInterface->setGameSettings(&gameSettings);
|
||||||
|
serverInterface->broadcastGameSetup(&gameSettings);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -237,6 +237,18 @@ ConnectionSlot* ServerInterface::getSlot(int playerIndex){
|
|||||||
return slots[playerIndex];
|
return slots[playerIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ServerInterface::hasClientConnection() {
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
||||||
|
if(slots[i] != NULL && slots[i]->isConnected() == true) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int ServerInterface::getConnectedSlotCount(){
|
int ServerInterface::getConnectedSlotCount(){
|
||||||
int connectedSlotCount= 0;
|
int connectedSlotCount= 0;
|
||||||
|
|
||||||
|
@@ -121,6 +121,7 @@ public:
|
|||||||
virtual bool getConnectHasHandshaked() const { return false; }
|
virtual bool getConnectHasHandshaked() const { return false; }
|
||||||
|
|
||||||
virtual void slotUpdateTask(ConnectionSlotEvent *event);
|
virtual void slotUpdateTask(ConnectionSlotEvent *event);
|
||||||
|
bool hasClientConnection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1);
|
void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1);
|
||||||
|
@@ -1567,7 +1567,9 @@ void ServerSocket::listen(int connectionQueueSize) {
|
|||||||
|
|
||||||
Socket *ServerSocket::accept()
|
Socket *ServerSocket::accept()
|
||||||
{
|
{
|
||||||
PLATFORM_SOCKET newSock= ::accept(sock, NULL, NULL);
|
struct sockaddr_in cli_addr;
|
||||||
|
socklen_t clilen = sizeof(cli_addr);
|
||||||
|
PLATFORM_SOCKET newSock= ::accept(sock, (struct sockaddr *) &cli_addr, &clilen);
|
||||||
if(isSocketValid(&newSock) == false)
|
if(isSocketValid(&newSock) == false)
|
||||||
{
|
{
|
||||||
char szBuf[1024]="";
|
char szBuf[1024]="";
|
||||||
@@ -1582,7 +1584,9 @@ Socket *ServerSocket::accept()
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got connection, newSock = %d\n",__FILE__,__FUNCTION__,__LINE__,newSock);
|
char client_host[100]="";
|
||||||
|
sprintf(client_host, "%s",inet_ntoa(cli_addr.sin_addr));
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got connection, newSock = %d client_host [%s]\n",__FILE__,__FUNCTION__,__LINE__,newSock,client_host);
|
||||||
}
|
}
|
||||||
return new Socket(newSock);
|
return new Socket(newSock);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user