void GameServerGroupInfoManager::load() throw(Error) { __BEGIN_TRY Statement * pStmt; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); Result* pResult = pStmt->executeQuery("SELECT MAX(`WorldID`) FROM `GameServerGroupInfo`"); if (pResult->getRowCount() == 0) throw Error("[GameServerGroupInfoManager] GameServerGroupInfo TABLE does not exist!"); pResult->next(); m_MaxWorldID = pResult->getInt(1) + 2; SAFE_DELETE(pStmt); } END_DB(pStmt) m_GameServerGroupInfos = new HashMapGameServerGroupInfo[m_MaxWorldID]; try { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); Result * pResult = pStmt->executeQuery("SELECT `WorldID`, `GroupID`, `GroupName` FROM `GameServerGroupInfo`"); while(pResult->next()) { GameServerGroupInfo * pGameServerGroupInfo = new GameServerGroupInfo(); WorldID_t WorldID = pResult->getInt(1); pGameServerGroupInfo->setWorldID(WorldID); pGameServerGroupInfo->setGroupID(pResult->getInt(2)); pGameServerGroupInfo->setGroupName(pResult->getString(3)); addGameServerGroupInfo(pGameServerGroupInfo, WorldID); } delete pStmt; } catch (SQLQueryException & sqe) { delete pStmt; throw Error(sqe.toString()); } catch (Throwable & t) { cout << t.toString() << endl; } __END_CATCH }
////////////////////////////////////////////////////////////////////////////// // 클라이언트가 PC 의 리스트를 달라고 요청해오면, 로그인 서버는 DB로부터 // PC들의 정보를 로딩해서 LCPCList 패킷에 담아서 전송한다. ////////////////////////////////////////////////////////////////////////////// void CLSelectServerHandler::execute (CLSelectServer* pPacket , Player* pPlayer) throw(ProtocolException , Error) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __LOGIN_SERVER__ Assert(pPacket != NULL); Assert(pPlayer != NULL); LoginPlayer* pLoginPlayer = dynamic_cast<LoginPlayer*>(pPlayer); ServerGroupID_t CurrentServerGroupID = pPacket->getServerGroupID(); WorldID_t WorldID = pLoginPlayer->getWorldID(); //Assert (WorldID <= g_pGameWorldInfoManager->getSize()); int MaxWorldID = g_pGameWorldInfoManager->getSize(); if (WorldID>MaxWorldID) { WorldID = MaxWorldID; } //Assert (CurrentServerGroupID <= g_pGameServerGroupInfoManager->getSize(WorldID )); int MaxServerGroupID = g_pGameServerGroupInfoManager->getSize(WorldID); if (CurrentServerGroupID>MaxServerGroupID) { CurrentServerGroupID = MaxServerGroupID; } // by sigi. 2003.1.7 GameServerGroupInfo* pGameServerGroupInfo = g_pGameServerGroupInfoManager->getGameServerGroupInfo(CurrentServerGroupID, WorldID); Assert(pGameServerGroupInfo!=NULL); if (pGameServerGroupInfo->getStat() == SERVER_DOWN) { filelog("errorLogin.txt", "Server Closed: %d", CurrentServerGroupID); throw DisconnectException("ServerClosed"); } pLoginPlayer->setServerGroupID(CurrentServerGroupID); //---------------------------------------------------------------------- // 이제 LCPCList 패킷을 만들어 보내자 //---------------------------------------------------------------------- LCPCList lcPCList; pLoginPlayer->makePCList(lcPCList); #ifdef __NETMARBLE_SERVER__ // 넷마블 사용자 약관 동의 여부 확인 lcPCList.setAgree(pLoginPlayer->isAgree()); #endif pLoginPlayer->sendPacket(&lcPCList); pLoginPlayer->setPlayerStatus(LPS_PC_MANAGEMENT); /* try { pStmt = g_pDatabaseManager->getConnection("DARKEDEN" )->createStatement(); pStmt->executeQuery("UPDATE Player set CurrentServerGroupID = %d WHERE PlayerID = '%s'", (int)pPacket->getServerGroupID(), pLoginPlayer->getID().c_str()); // 쿼리 결과 및 쿼리문 객체를 삭제한다. SAFE_DELETE(pStmt); } catch (SQLQueryException & sce) { //cout << sce.toString() << endl; // 쿼리 결과 및 쿼리문 객체를 삭제한다. SAFE_DELETE(pStmt); throw DisconnectException(sce.toString()); }*/ #endif __END_DEBUG_EX __END_CATCH }
////////////////////////////////////////////////////////////////////////////// // 클라이언트가 서버의 리스트를 달라고 요청해오면, 로그인 서버는 DB로부터 // 서버들의 정보를 로딩해서 LCServerList 패킷에 담아서 전송한다. ////////////////////////////////////////////////////////////////////////////// void CLGetServerListHandler::execute (CLGetServerList* pPacket , Player* pPlayer) throw(ProtocolException , Error) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __LOGIN_SERVER__ Assert(pPacket != NULL); Assert(pPlayer != NULL); //cout << "Start execute" << endl; LoginPlayer* pLoginPlayer = dynamic_cast<LoginPlayer*>(pPlayer); WorldID_t WorldID = pLoginPlayer->getWorldID(); try { int GroupNum = g_pGameServerGroupInfoManager->getSize(WorldID); //cout << "ServerNum : " << GroupNum << endl; ServerGroupInfo* aServerGroupInfo[GroupNum]; for(int i = 0 ; i < GroupNum; i++) { ServerGroupInfo* pServerGroupInfo = new ServerGroupInfo(); GameServerGroupInfo* pGameServerGroupInfo = g_pGameServerGroupInfoManager->getGameServerGroupInfo(i, WorldID); pServerGroupInfo->setGroupID(pGameServerGroupInfo->getGroupID()); pServerGroupInfo->setGroupName(pGameServerGroupInfo->getGroupName()); pServerGroupInfo->setStat(SERVER_FREE); UserInfo * pUserInfo = g_pUserInfoManager->getUserInfo(pGameServerGroupInfo->getGroupID(), WorldID); WORD UserModify = 800; WORD UserMax = 1500; if (pUserInfo->getUserNum() < 100 + UserModify ) { pServerGroupInfo->setStat(SERVER_FREE); } else if (pUserInfo->getUserNum() < 250 + UserModify ) { pServerGroupInfo->setStat(SERVER_NORMAL); } else if (pUserInfo->getUserNum() < 400 + UserModify ) { pServerGroupInfo->setStat(SERVER_BUSY); } else if (pUserInfo->getUserNum() < 500 + UserModify ) { pServerGroupInfo->setStat(SERVER_VERY_BUSY); } else //if (pUserInfo->getUserNum() >= 500 + UserModify ) { pServerGroupInfo->setStat(SERVER_FULL); } //else { //pServerGroupInfo->setStat(SERVER_DOWN); } if (pUserInfo->getUserNum() >= UserMax) { pServerGroupInfo->setStat(SERVER_FULL); } if (pGameServerGroupInfo->getStat() == SERVER_DOWN ) { pServerGroupInfo->setStat(SERVER_DOWN); } aServerGroupInfo[i] = pServerGroupInfo; //cout << "AddServer : " << pServerGroupInfo->getGroupName() << endl; } LCServerList lcServerList; Statement * pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); Result * pResult = pStmt->executeQuery("SELECT CurrentWorldID, CurrentServerGroupID FROM Player where PlayerID='%s'" , pLoginPlayer->getID().c_str()); if(pResult->next() ) { lcServerList.setCurrentServerGroupID(pResult->getInt(1)); lcServerList.setCurrentServerGroupID(pResult->getInt(2)); } SAFE_DELETE(pStmt); // by sigi } END_DB(pStmt) // by sigi for(int k = 0; k < GroupNum; k++) { lcServerList.addListElement(aServerGroupInfo[k]); } pLoginPlayer->sendPacket(&lcServerList); pLoginPlayer->setPlayerStatus(LPS_PC_MANAGEMENT); } catch (Throwable & t) { //cout << t.toString() << endl; } //cout << "End execute" << endl; #endif __END_DEBUG_EX __END_CATCH }