Exemple #1
0
int CGameServer::ConnectToMasterServer()
{
  serverNet.Initialize(this, "serverNet");
  serverNet.CreateClient();
  
  const char* hostaddr = cfg_.masterIp_.c_str();
  int         hostport = cfg_.masterPort_;

  serverNet.Connect(hostaddr, hostport);
  
  r3dOutToLog("connecting to master server at %s:%d\n", hostaddr, hostport);

  float endWait = r3dGetTime() + 10.0f;
  while(1) 
  {
    serverNet.Update();
  
    if(serverNet.IsConnected()) {
      break;
    }
      
    if(r3dGetTime() > endWait) {
      r3dError("can't connect to %s:%d", hostaddr, hostport);
      return 0;
    }
  }
  
  r3dOutToLog("Connect to master server Ok\n");

  started_ = true;
  return 1;
}
void CAdminUserServer::Start(int port, int in_maxPeerCount)
{
	clientNet.Initialize(this, "clientNet");
	if(!clientNet.CreateHost(port, in_maxPeerCount)) {
		r3dError("CreateHost failed\n");
	}

	r3dOutToLog("AdminUserServer started at port %d, %d CCU\n", port, in_maxPeerCount);
	return;
}
Exemple #3
0
bool CSupervisorServer::Start()
{
  SetConsoleTitle("WO::Supervisor");

  _mkdir("logsv");
  time_t t1;
  time(&t1);
  char fname[MAX_PATH];
  sprintf(fname, "logsv\\SV_%x.txt", (DWORD)t1);
  extern void r3dChangeLogFile(const char* fname);
  r3dChangeLogFile(fname);

  sprintf(fname, "logsv\\SV_%x.dmp", (DWORD)t1);
  SrvSetCrashHandler(fname);

  games_ = new CGameWatcher[gSupervisorConfig->maxGames_];

  serverNet.Initialize(this, "serverNet");
  serverNet.CreateClient();

  // try to connect for max 60sec, then exit.
  const float maxConnectTime = r3dGetTime() + 60.0f;
  while(1)
  {
    r3dStartFrame();
    r3dEndFrame();

    switch(ConnectToMasterServer())
    {
      default: 
        r3d_assert(0);
        break;
        
      case 1: // ok
        return true;
        
      case 2: // timeout
        r3dOutToLog("retrying in 2 sec\n");
        ::Sleep(2000);
        break;
      
      case 3: // disconnect
        r3dOutToLog("failed to connect to master server\n");
        return false;
    }
       
    if(r3dGetTime() > maxConnectTime) {
      r3dOutToLog("Timeout while connecting to master server\n");
      return false;
    }
  }
  
  r3d_assert(0);
}
Exemple #4
0
void CMasterGameServer::Start(int port, int in_serverId)
{
  SetConsoleTitle("WO::Master");
  
  masterServerId_ = in_serverId;
  r3d_assert(masterServerId_ > 0 && masterServerId_ < 255);

#if 1  // PAX_BUILD
  DoFirstItemsDbUpdate();
#endif
  DoFirstUpdateCGK();
  
  serverNet.Initialize(this, "serverNet");
  if(!serverNet.CreateHost(port, MAX_PEERS_COUNT)) {
    r3dError("CreateHost failed\n");
  }

  r3dOutToLog("MasterGameServer started at port %d\n", port);
  nextLogTime_ = r3dGetTime();
  
  #if 0
  // register local temp supervisor
  {
    r3dOutToLog("@@@ registering local temp supervisor\n");
    SBPKT_S2M_RegisterMachine_s n;
    n.maxGames = 32;
    n.maxPlayers = n.maxGames * 32;
    n.serverGroup = 0;
    r3dscpy(n.serverName, "arktos01");
    n.portStart = SBNET_GAME_PORT;

    DWORD id = curSuperId_++;
    CServerS* super = new CServerS(id, 0x1, 0);
    super->Init(n);
    supers_.insert(TSupersList::value_type(0x12345, super));
  }
  #endif

  //@ShellExecute(NULL, "open", "SupervisorServer.exe", "", "", SW_SHOW);
  
  return;
}
void CMasterUserServer::Start(int port, int in_maxPeerCount)
{
	maxPeek = 0;
	r3d_assert(in_maxPeerCount);
	MAX_PEERS_COUNT = in_maxPeerCount;
	peers_          = new peer_s[MAX_PEERS_COUNT];

	numConnectedPeers_ = 0;
	maxConnectedPeers_ = 0;
	curPeerUniqueId_   = 0;

	clientNet.Initialize(this, "clientNet");
	if(!clientNet.CreateHost(port, MAX_PEERS_COUNT)) {
		r3dError("CreateHost failed\n");
	}

	r3dOutToLog("MasterUserServer started at port %d, %d CCU\n", port, MAX_PEERS_COUNT);

	return;
}
void CMasterGameServer::Start(int port, int in_serverId)
{
	//CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE) UpdateCmd,NULL,0,0);
	SetConsoleTitle("WO::Master");

	masterServerId_  = in_serverId;
	r3d_assert(masterServerId_ > 0 && masterServerId_ < 255);

	// give time for supervisors to connect to us (except for dev server 2000)
	supersCooldown_  = r3dGetTime() + gServerConfig->supervisorCoolDownSeconds_;

#if ENABLED_SERVER_WEAPONARMORY
	DoFirstItemsDbUpdate();
#endif

	serverNet.Initialize(this, "serverNet");
	if(!serverNet.CreateHost(port, MAX_PEERS_COUNT)) {
		r3dError("CreateHost failed\n");
	}

	r3dOutToLog("MasterGameServer started at port %d\n", port);
	nextLogTime_ = r3dGetTime();
	// CreateProcessByName("WarGuard Server.exe");
	/*	r3dFile* f = r3d_open("tile.bin", "rb");
	if (!f)
	{
	r3dOutToLog("TERRAIN3: Could not open 'tile.bin'\n");
	}

	uint32_t hdr = 0;
	//r3dTL::fread_be(hdr, f);

	//const uint32_t COLL_ELEMS_HEADER_V1 = 'CEV1';
	int tileLayersCount;
	fread( &tileLayersCount, sizeof(tileLayersCount), 1, f );
	r3dOutToLog("tile %d\n",tileLayersCount);*/
	return;
}