//---------------------------------------------------------------------- // 클라이언트가 게임 서버로부터 GCUpdateInfo 패킷을 받게 되면, // 패킷 안의 데이터들을 클라이언트에 저장한 후, 데이터 로딩이 // 끝이 나면 게임 서버로 CGReady 패킷을 보내면 된다. //---------------------------------------------------------------------- void GCUpdateInfoHandler::execute (GCUpdateInfo * pPacket , Player * pPlayer ) throw(ProtocolException , Error ) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_CLIENT__ ClientPlayer * pClientPlayer = dynamic_cast<ClientPlayer*>(pPlayer); //cout << pPacket->toString() << endl; //-------------------------------------------------- // 데이터 로딩을 시작한다. //-------------------------------------------------- pClientPlayer->setPlayerStatus(CPS_WAITING_FOR_LOADING); // ... 로딩 로딩 ... //-------------------------------------------------- // 게임 서버로 CGReady 패킷을 보낸다. //-------------------------------------------------- CGReady cgReady; pClientPlayer->sendPacket(&cgReady); pClientPlayer->setPlayerStatus(CPS_WAITING_FOR_GC_SET_POSITION); #endif __END_DEBUG_EX __END_CATCH }
//-------------------------------------------------------------------------------- // 로그인서버로부터 게임 서버의 주소와 포트, 그리고 인증키를 받은 즉시 // 게임 서버로 연결한 후, 인증키를 담은 CGConnect 패킷을 전송한다. //-------------------------------------------------------------------------------- void LCReconnectHandler::execute (LCReconnect * pPacket , Player * pPlayer ) throw(ProtocolException , Error ) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_CLIENT__ ClientPlayer * pClientPlayer = dynamic_cast<ClientPlayer*>(pPlayer); // 로그인 서버와의 연결을 종료한다 // 이때 로그인 서버는 LCReconnect 패킷을 보내면서 연결을 종료한다는 사실에 유의하라. //cout << "Disconnecting from login server" << endl; pClientPlayer->disconnect(); // LCReconnect 패킷에 들어있는 정보를 사용해서, 게임 서버로 연결한다. //cout << "Reconnecting to " << pPacket->getGameServerIP() << ":" << pPacket->getGameServerPort() << endl; try { pClientPlayer->getSocket()->reconnect(pPacket->getGameServerIP() , pPacket->getGameServerPort()); // reconnect하게 되면 소켓이 새로 만들어지게 된다. // 따라서, 이 소켓 역시 옵션을 새로 지정해줘야 한다. pClientPlayer->getSocket()->setNonBlocking(); pClientPlayer->getSocket()->setLinger(0); } catch (ConnectException & ce ) { throw Error(ce.toString()); } // 연결이 이루어지면, 바로 CGConnect 패킷을 전송한다. // 이전에 Select 한 PC의 타입과 이름을 클라이언트 플레이어 객체에 저장해둔다. //cout << "Sending CGConnect with Key(" << pPacket->getKey() << ")" << endl; CGConnect cgConnect; cgConnect.setKey(pPacket->getKey()); cgConnect.setPCType(pClientPlayer->getPCType()); cgConnect.setPCName(pClientPlayer->getPCName()); pClientPlayer->sendPacket(&cgConnect); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CG_CONNECT); #endif __END_DEBUG_EX __END_CATCH }
//-------------------------------------------------------------------------------- // // 플레이어 등록이 성공적으로 끝났으면, 로그인 서버에게 PC LIST 를 요청한다. // //-------------------------------------------------------------------------------- void LCRegisterPlayerOKHandler::execute (LCRegisterPlayerOK * pPacket , Player * pPlayer ) throw(ProtocolException , Error ) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_CLIENT__ ClientPlayer * pClientPlayer = dynamic_cast<ClientPlayer*>(pPlayer); //cout << "Player Registeration Successfull." << endl; CLGetPCList clGetPCList; pClientPlayer->sendPacket(&clGetPCList); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_GET_PC_LIST); #endif __END_DEBUG_EX __END_CATCH }
//---------------------------------------------------------------------- // 서버로부터 캐릭터 리스트를 받았다. // 이제 캐릭터 관리 인터페이스의 적절한 곳에 전송받은 값을 집어 넣어서 // 출력하자. //---------------------------------------------------------------------- void LCPCListHandler::execute (LCPCList * pPacket , Player * pPlayer ) throw(ProtocolException , Error ) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_CLIENT__ #if __LINUX__ || __WIN_CONSOLE__ ClientPlayer * pClientPlayer = (ClientPlayer*)pPlayer; cout << endl << "+----------------------+" << endl << "| CHARACTER MANAGEMENT |" << endl << "+----------------------+" << endl << endl; uint nPCs = 0; for (uint i = 0 ; i < SLOT_MAX ; i ++ ) { try { PCInfo * pPCInfo = pPacket->getPCInfo(Slot(i)); nPCs ++; switch (pPCInfo->getPCType() ) { case PC_SLAYER : { PCSlayerInfo * pPCSlayerInfo = dynamic_cast<PCSlayerInfo*>(pPCInfo); cout << pPCSlayerInfo->toString() << endl; } break; case PC_VAMPIRE : { PCVampireInfo * pPCVampireInfo = dynamic_cast<PCVampireInfo*>(pPCInfo); cout << pPCVampireInfo->toString() << endl; } break; case PC_OUSTERS : { PCOustersInfo * pPCOustersInfo = dynamic_cast<PCOustersInfo*>(pPCInfo); cout << pPCOustersInfo->toString() << endl; } break; default : throw InvalidProtocolException("invalid pc type"); } } catch (NoSuchElementException ) { } } if (nPCs == 0 ) { //cout << "캐릭터가 하나도 없습니다." << endl; } char cmd[80+1]; do { cout << endl << "+--------------+" << endl << "| 1. Create PC |" << endl << "| 2. Delete PC |" << endl << "| 3. Select PC |" << endl << "| 4. To Board |" << endl << "+--------------|" << endl << "select > "; cin.getline(cmd,80); } while (strcmp(cmd,"1") != 0 && strcmp(cmd,"2") != 0 && strcmp(cmd,"3") != 0 && strcmp(cmd, "4") !=0); if (strcmp(cmd,"1") == 0 ) { cout << endl << "+--------------------+" << endl << "| CHARACTER CREATION |" << endl << "+--------------------+" << endl << endl; CLCreatePC clCreatePC; cout << "Name : "; cin.getline(cmd,80); clCreatePC.setName(cmd); cout << "Slot (1-3) : "; cin.getline(cmd,80); Slot slot; if (strcmp(cmd,"1") == 0 ) slot = SLOT1; else if (strcmp(cmd,"2") == 0 ) slot = SLOT2; else if (strcmp(cmd,"3") == 0 ) slot = SLOT3; else slot = SLOT1; clCreatePC.setSlot(slot); cout << "Sex (남/여) : "; cin.getline(cmd,80); Sex sex = (strcmp(cmd,"남") == 0 ) ? sex = MALE : sex = FEMALE; clCreatePC.setSex(sex); cout << "Sex : " << Sex2String[sex] << endl; cout << "HairStyle (1-3) : "; cin.getline(cmd,80); HairStyle hairStyle; if (strcmp(cmd,"1") == 0 ) hairStyle = HAIR_STYLE1; else if (strcmp(cmd,"2") == 0 ) hairStyle = HAIR_STYLE2; else if (strcmp(cmd,"3") == 0 ) hairStyle = HAIR_STYLE3; else hairStyle = HAIR_STYLE1; clCreatePC.setHairStyle(hairStyle); cout << "HairColor (0-255) : "; cin.getline(cmd,80); clCreatePC.setHairColor(atoi(cmd )); cout << "SkinColor (0-255) : "; cin.getline(cmd,80); clCreatePC.setSkinColor(atoi(cmd )); cout << "ShirtColor (0-255) : "; cin.getline(cmd,80); clCreatePC.setSkinColor(atoi(cmd )); cout << "JeansColor (0-255) : "; cin.getline(cmd,80); clCreatePC.setSkinColor(atoi(cmd )); cout << "Try to creating PC : " << clCreatePC.toString() << endl; pClientPlayer->sendPacket(&clCreatePC); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_CREATE_PC); } else if (strcmp(cmd,"2") == 0 ) { cout << endl << "+------------------+" << endl << "| DELETE CHARACTER |" << endl << "+------------------+" << endl << endl; CLDeletePC clDeletePC; cout << "Name : "; cin.getline(cmd,80); clDeletePC.setName(cmd); cout << "Slot (1-3) : "; cin.getline(cmd,80); Slot slot; if (strcmp(cmd,"1") == 0 ) slot = SLOT1; else if (strcmp(cmd,"2") == 0 ) slot = SLOT2; else if (strcmp(cmd,"3") == 0 ) slot = SLOT3; else slot = SLOT1; clDeletePC.setSlot(slot); pClientPlayer->sendPacket(&clDeletePC); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_DELETE_PC); } else if (strcmp(cmd,"3") == 0 ) { cout << endl << "+------------------+" << endl << "| SELECT CHARACTER |" << endl << "+------------------+" << endl << endl; CLSelectPC clSelectPC; cout << "Name : "; cin.getline(cmd,80); clSelectPC.setPCName(cmd); cout << "PCType (S/V) : "; cin.getline(cmd,80); if (strcmp(cmd,"S") == 0 || strcmp(cmd,"s") == 0 ) clSelectPC.setPCType(PC_SLAYER); else if (strcmp(cmd,"V") == 0 || strcmp(cmd,"v") == 0 ) clSelectPC.setPCType(PC_VAMPIRE); else clSelectPC.setPCType(PC_SLAYER); // CGConnect 때 사용하려면 여기서 저장해둬야 한다. pClientPlayer->setPCType(clSelectPC.getPCType()); pClientPlayer->setPCName(clSelectPC.getPCName()); cout << endl << clSelectPC.toString() << endl; pClientPlayer->sendPacket(&clSelectPC); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_SELECT_PC); } else if (strcmp(cmd, "4") == 0 ) { cout<< endl; cout<<"Choose BBS" <<endl << "+------------------+" << endl << "| 1. Beta BBS |" << endl << "| 2. Quit |" << endl << "| |" << endl << "+------------------+" << endl << "select > "; // 여기에 게시판 관련 처리 부분이 들어가면 된다.. // CLSelectBBS 패킷을 만들어서 보내면 되겠군... cin.getline(cmd,80); if (strcmp(cmd, "1") == 0 ) { CLSelectBoard clSelectBoard; clSelectBoard.setBoardName("BetaBBS"); cout << clSelectBoard.toString() << endl; pClientPlayer->sendPacket(&clSelectBoard); pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_SELECT_BOARD); } } #endif #endif __END_DEBUG_EX __END_CATCH }
//-------------------------------------------------------------------------------- // // // //-------------------------------------------------------------------------------- void LCRegisterPlayerErrorHandler::execute (LCRegisterPlayerError * pPacket , Player * pPlayer ) throw(ProtocolException , Error ) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_CLIENT__ ClientPlayer * pClientPlayer = dynamic_cast<ClientPlayer*>(pPlayer); cout << endl << "+-------------------------+" << endl << "| FAIL TO REGISTER PLAYER |" << endl << "+-------------------------+" << endl << endl << pPacket->getMessage() << endl; cout << endl << "+-----------------+" << endl << "| REGISTER PLAYER |" << endl << "+-----------------+" << endl << endl; CLRegisterPlayer clRegisterPlayer; char cmd[80]; cout << "아이디 : "; cin.getline(cmd,80); clRegisterPlayer.setID(cmd); cout << "패스워드 : "; cin.getline(cmd,80); clRegisterPlayer.setPassword(cmd); cout << "이름 : "; cin.getline(cmd,80); clRegisterPlayer.setName(cmd); cout << "성별 (남/여) : "; cin.getline(cmd,80); Sex sex; if (strcmp(cmd,"남") == 0 ) sex = MALE; if (strcmp(cmd,"여") == 0 ) sex = FEMALE; else sex = MALE; cout << "Sex : " << Sex2String[sex] << endl; clRegisterPlayer.setSex(sex); clRegisterPlayer.setSSN("800101-2000111"); clRegisterPlayer.setTelephone("02-222-3333"); clRegisterPlayer.setCellular("011-222-3333"); clRegisterPlayer.setZipCode("700-441"); clRegisterPlayer.setAddress("서울특별시 영등포구 여의도동 사서함 300번지"); clRegisterPlayer.setNation(KOREA); clRegisterPlayer.setEmail("*****@*****.**"); clRegisterPlayer.setHomepage("www.jhkim.com"); clRegisterPlayer.setProfile("테크노의 여왕 전지현"); clRegisterPlayer.setPublic(false); cout << clRegisterPlayer.toString() << endl; // 등록 패킷을 전송한다. pClientPlayer->sendPacket(&clRegisterPlayer); // 플레이어의 상태를 바꾼다. pClientPlayer->setPlayerStatus(CPS_AFTER_SENDING_CL_REGISTER_PLAYER); #endif __END_DEBUG_EX __END_CATCH }