bool LoginServer::Startup() { GetInfoFromIni(); DateTime time; CreateDirectory("Logs",NULL); m_fpLoginServer = fopen("./Logs/LoginServer.log", "a"); if (m_fpLoginServer == nullptr) { printf("ERROR: Unable to open log file.\n"); return false; } m_fpUser = fopen(string_format("./Logs/Login_%d_%d_%d.log",time.GetDay(),time.GetMonth(),time.GetYear()).c_str(), "a"); if (m_fpUser == nullptr) { printf("ERROR: Unable to open user log file.\n"); return false; } if (!m_DBProcess.Connect(m_ODBCName, m_ODBCLogin, m_ODBCPwd)) { printf("ERROR: Unable to connect to the database using the details configured.\n"); return false; } printf("Connected to database server.\n"); if (!m_DBProcess.LoadVersionList()) { printf("ERROR: Unable to load the version list.\n"); return false; } printf("Latest version in database: %d\n", GetVersion()); InitPacketHandlers(); if (!m_socketMgr.Listen(m_LoginServerPort, MAX_USER)) { printf("ERROR: Failed to listen on server port.\n"); return false; } m_socketMgr.RunServer(); g_timerThreads.push_back(new Thread(Timer_UpdateUserCount)); return true; }
void NetworkInit (void) { int nPlayerSave = gameData.multiplayer.nLocalPlayer; GameDisableCheats (); gameStates.multi.bIWasKicked = 0; gameStates.gameplay.bFinalBossIsDead = 0; networkData.nNamesInfoSecurity = -1; #ifdef NETPROFILING OpenSendLog (); OpenReceiveLog (); #endif InitAddressFilter (); InitPacketHandlers (); memset (gameData.multiplayer.maxPowerupsAllowed, 0, sizeof (gameData.multiplayer.maxPowerupsAllowed)); memset (gameData.multiplayer.powerupsInMine, 0, sizeof (gameData.multiplayer.powerupsInMine)); networkData.nTotalMissedPackets = 0; networkData.nTotalPacketsGot = 0; memset (&netGame, 0, sizeof (tNetgameInfo)); memset (&netPlayers, 0, sizeof (tAllNetPlayersInfo)); networkData.thisPlayer.nType = PID_REQUEST; memcpy (networkData.thisPlayer.player.callsign, LOCALPLAYER.callsign, CALLSIGN_LEN+1); networkData.thisPlayer.player.versionMajor=D2X_MAJOR; networkData.thisPlayer.player.versionMinor=D2X_MINOR | (IS_D2_OEM ? NETWORK_OEM : 0); networkData.thisPlayer.player.rank=GetMyNetRanking (); if (gameStates.multi.nGameType >= IPX_GAME) { memcpy (networkData.thisPlayer.player.network.ipx.node, IpxGetMyLocalAddress (), 6); if (gameStates.multi.nGameType == UDP_GAME) * ((ushort *) (networkData.thisPlayer.player.network.ipx.node + 4)) = htons (* ((ushort *) (networkData.thisPlayer.player.network.ipx.node + 4))); // if (gameStates.multi.nGameType == UDP_GAME) // memcpy (networkData.thisPlayer.player.network.ipx.node, ipx_LocalAddress + 4, 4); memcpy (networkData.thisPlayer.player.network.ipx.server, IpxGetMyServerAddress (), 4); } networkData.thisPlayer.player.computerType = DOS; for (gameData.multiplayer.nLocalPlayer = 0; gameData.multiplayer.nLocalPlayer < MAX_NUM_NET_PLAYERS; gameData.multiplayer.nLocalPlayer++) InitPlayerStatsGame (); gameData.multiplayer.nLocalPlayer = nPlayerSave; MultiNewGame (); networkData.bNewGame = 1; gameData.reactor.bDestroyed = 0; NetworkFlush (); netGame.nPacketsPerSec = mpParams.nPPS; }
bool LoginServer::Startup() { GetInfoFromIni(); m_fp = fopen("./Login.log", "a"); if (m_fp == nullptr) { printf("ERROR: Unable to open log file.\n"); return false; } if (!m_DBProcess.Connect(m_ODBCName, m_ODBCLogin, m_ODBCPwd)) { printf("ERROR: Unable to connect to the database using the details configured.\n"); return false; } printf("Connected to database server.\n"); if (!m_DBProcess.LoadVersionList()) { printf("ERROR: Unable to load the version list.\n"); return false; } printf("Latest version in database: %d\n", GetVersion()); InitPacketHandlers(); if (!m_socketMgr.Listen(_LISTEN_PORT, MAX_USER)) { printf("ERROR: Failed to listen on server port.\n"); return false; } m_socketMgr.RunServer(); g_timerThreads.push_back(new Thread(Timer_UpdateUserCount)); return true; }