void CAISocket::RecvUserFail(char* pBuf) { short nid = 0, sid=0; int index = 0, send_index = 0; char pOutBuf[1024]; nid = GetShort(pBuf,index); sid = GetShort(pBuf,index); CUser* pUser = m_pMain->GetUserPtr(nid); if (pUser == NULL) return; pUser->HpChange(-10000, 1); BYTE type = 0x01; BYTE result = 0x02; float fDir = 0.0f; SetByte(pOutBuf, WIZ_ATTACK, send_index); SetByte( pOutBuf, type, send_index ); SetByte( pOutBuf, result, send_index ); SetShort( pOutBuf, sid, send_index ); SetShort( pOutBuf, nid, send_index ); TRACE("### AISocket - RecvUserFail : sid=%d, tid=%d, id=%s ####\n", sid, nid, pUser->m_pUserData->m_id); m_pMain->Send_Region(pOutBuf, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ); }
void CUdpSocket::RecvDestroyKnights( char* pBuf ) { int send_index = 0, knightsindex = 0, index = 0, flag = 0; char send_buff[128]; memset( send_buff, 0x00, 128 ); char finalstr[128]; memset( finalstr, 0x00, 128 ); CKnights* pKnights = NULL; CUser* pTUser = NULL; knightsindex = GetShort( pBuf, index ); pKnights = m_pMain->m_KnightsArray.GetData( knightsindex ); if( !pKnights ) { TRACE("UDP - ### RecvDestoryKnights Fail == index = %d ###\n", knightsindex); return; } flag = pKnights->m_byFlag; // 클랜이나 기사단이 파괴된 메시지를 보내고 유저 데이타를 초기화 if( flag == CLAN_TYPE) sprintf( finalstr, "#### %s 클랜이 해체되었습니다 ####", pKnights->m_strName ); else if( flag == KNIGHTS_TYPE ) sprintf( finalstr, "#### %s 기사단이 해체되었습니다 ####", pKnights->m_strName ); memset( send_buff, 0x00, 128 ); send_index = 0; SetByte( send_buff, WIZ_CHAT, send_index ); SetByte( send_buff, KNIGHTS_CHAT, send_index ); SetByte( send_buff, 1, send_index ); SetShort( send_buff, -1, send_index ); SetShort( send_buff, strlen(finalstr), send_index ); SetString( send_buff, finalstr, strlen(finalstr), send_index ); m_pMain->Send_KnightsMember( knightsindex, send_buff, send_index ); for (int i = 0; i < MAX_USER; i++) { pTUser = m_pMain->GetUnsafeUserPtr(i); if (pTUser == NULL || pTUser->m_pUserData->m_bKnights != knightsindex) continue; pTUser->m_pUserData->m_bKnights = 0; pTUser->m_pUserData->m_bFame = 0; m_pMain->m_KnightsManager.RemoveKnightsUser( knightsindex, pTUser->m_pUserData->m_id ); memset( send_buff, 0x00, 128 ); send_index = 0; SetByte( send_buff, WIZ_KNIGHTS_PROCESS, send_index ); SetByte( send_buff, KNIGHTS_MODIFY_FAME, send_index ); SetByte( send_buff, 0x01, send_index ); SetShort( send_buff, pTUser->GetSocketID(), send_index ); SetShort( send_buff, pTUser->m_pUserData->m_bKnights, send_index ); SetByte( send_buff, pTUser->m_pUserData->m_bFame, send_index ); m_pMain->Send_Region( send_buff, send_index, pTUser->GetMap(), pTUser->m_RegionX, pTUser->m_RegionZ, NULL, false ); } m_pMain->m_KnightsArray.DeleteData( knightsindex ); //TRACE("UDP - RecvDestoryKnights - index=%d\n", knightsindex); }
void CAISocket::RecvMagicAttackResult(Packet & pkt) { uint32 magicid; uint16 sid, tid; uint8 byCommand; /* This is all so redundant... When everything's switched over to pass in Packets we can just pass it through directly! As it is now.. we still need a length (which we can hardcode, but meh) */ pkt >> byCommand >> magicid >> sid >> tid; if (byCommand == MAGIC_CASTING || (byCommand == MAGIC_EFFECTING && sid >= NPC_BAND && tid >= NPC_BAND)) { CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sid); if (!pNpc) return; g_pMain->Send_Region(&pkt, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z); } else if (byCommand == MAGIC_EFFECTING) { if (sid >= USER_BAND && sid < NPC_BAND) { CUser *pUser = g_pMain->GetUserPtr(sid); if (pUser == NULL || pUser->isDead()) return; g_pMain->Send_Region(&pkt, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ); return; } // If we're an NPC, casting a skill (rather, it's finished casting) on a player... pkt.rpos(0); m_MagicProcess.MagicPacket(pkt); } }
bool CGameSocket::SetUid(float x, float z, int id, int speed) { int x1 = (int)x / TILE_SIZE; int z1 = (int)z / TILE_SIZE; int nRX = (int)x / VIEW_DIST; int nRZ = (int)z / VIEW_DIST; CUser* pUser = g_pMain->GetUserPtr(id); if(pUser == nullptr) { TRACE("#### User등록 실패 sid = %d ####\n", id); return false; } MAP* pMap = pUser->GetMap(); if (pMap == nullptr) { TRACE("#### User not in valid zone, sid = %d ####\n", id); return false; } if(x1 < 0 || z1 < 0 || x1 >= pMap->GetMapSize() || z1 >= pMap->GetMapSize()) { TRACE("#### GameSocket ,, SetUid Fail : [nid=%d, name=%s], x1=%d, z1=%d #####\n", id, pUser->GetName().c_str(), x1, z1); return false; } if(nRX > pMap->GetXRegionMax() || nRZ > pMap->GetZRegionMax()) { TRACE("#### GameSocket , SetUid Fail : [nid=%d, name=%s], nRX=%d, nRZ=%d #####\n", id, pUser->GetName().c_str(), nRX, nRZ); return false; } // if(pMap->m_pMap[x1][z1].m_sEvent == 0) return false; if (pUser != nullptr) { if (pUser->m_bLive == AI_USER_DEAD || pUser->m_sHP <= 0) return false; ///// attack ~ if( speed != 0 ) { pUser->m_curx = pUser->m_fWill_x; pUser->m_curz = pUser->m_fWill_z; pUser->m_fWill_x = x; pUser->m_fWill_z = z; } else { pUser->m_curx = pUser->m_fWill_x = x; pUser->m_curz = pUser->m_fWill_z = z; } /////~ attack if(pUser->m_sRegionX != nRX || pUser->m_sRegionZ != nRZ) { pMap->RegionUserRemove(pUser->m_sRegionX, pUser->m_sRegionZ, id); pUser->m_sRegionX = nRX; pUser->m_sRegionZ = nRZ; pMap->RegionUserAdd(pUser->m_sRegionX, pUser->m_sRegionZ, id); } } // dungeon work int room = pMap->IsRoomCheck( x, z ); return true; }
void CGameSocket::RecvUserInOut(Packet & pkt) { std::string strUserID; uint8 bType; uint16 uid; float fX, fZ; pkt.SByte(); pkt >> bType >> uid >> strUserID >> fX >> fZ; if (fX < 0 || fZ < 0) { TRACE("Error:: RecvUserInOut(),, uid = %d, fX=%.2f, fZ=%.2f\n", uid, fX, fZ); return; } int region_x = 0, region_z=0; int x1 = (int)fX / TILE_SIZE; int z1 = (int)fZ / TILE_SIZE; region_x = (int)fX / VIEW_DIST; region_z = (int)fZ / VIEW_DIST; // 수정할것,,, : 지금 존 번호를 0으로 했는데.. 유저의 존 정보의 번호를 읽어야,, 함,, MAP* pMap = nullptr; CUser* pUser = g_pMain->GetUserPtr(uid); if(pUser != nullptr) { // TRACE("##### Fail : ^^& RecvUserInOut() [name = %s]. state=%d, hp=%d\n", pUser->GetName().c_str(), pUser->m_bLive, pUser->m_sHP); if(pUser->m_bLive == AI_USER_DEAD || pUser->m_sHP <= 0) { if(pUser->m_sHP > 0) { pUser->m_bLive = true; TRACE("##### CGameSocket-RecvUserInOut Fail : UserHeal [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->GetName().c_str(), pUser->m_bLive, pUser->m_sHP, fX, fZ); } else { TRACE("##### CGameSocket-RecvUserInOut Fail : UserDead [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->GetName().c_str(), pUser->m_bLive, pUser->m_sHP, fX, fZ); // 죽은 유저이므로 게임서버에 죽은 처리를 한다... //Send_UserError(uid); //return; } } pMap = pUser->GetMap(); if(pMap == nullptr) { TRACE("#### Fail : pMap == nullptr ####\n"); return; } if(x1 < 0 || z1 < 0 || x1 >= pMap->GetMapSize() || z1 >= pMap->GetMapSize()) { TRACE("#### RecvUserInOut Fail : [name=%s], x1=%d, z1=%d #####\n", pUser->GetName().c_str(), region_x, region_z); return; } //if(pMap->m_pMap[x1][z1].m_sEvent == 0) return; if(region_x > pMap->GetXRegionMax() || region_z > pMap->GetZRegionMax()) { TRACE("#### GameSocket-RecvUserInOut() Fail : [name=%s], nRX=%d, nRZ=%d #####\n", pUser->GetName().c_str(), region_x, region_z); return; } pUser->m_curx = pUser->m_fWill_x = fX; pUser->m_curz = pUser->m_fWill_z = fZ; // leaving a region if (bType == 2) { pMap->RegionUserRemove(region_x, region_z, uid); } // entering a region else if (pUser->m_sRegionX != region_x || pUser->m_sRegionZ != region_z) { pUser->m_sRegionX = region_x; pUser->m_sRegionZ = region_z; pMap->RegionUserAdd(region_x, region_z, uid); } } }
void CGameSocket::RecvUserInOut(Packet & pkt) { std::string strUserID; uint8 bType; uint16 uid; float fX, fZ; pkt.SByte(); pkt >> bType >> uid >> strUserID >> fX >> fZ; if (fX < 0 || fZ < 0) { TRACE("Error:: RecvUserInOut(),, uid = %d, fX=%.2f, fZ=%.2f\n", uid, fX, fZ); return; } int region_x = 0, region_z=0; int x1 = (int)fX / TILE_SIZE; int z1 = (int)fZ / TILE_SIZE; region_x = (int)fX / VIEW_DIST; region_z = (int)fZ / VIEW_DIST; MAP* pMap = nullptr; CUser* pUser = g_pMain->GetUserPtr(uid); if (pUser == nullptr) return; pMap = pUser->GetMap(); if (pMap == nullptr) { TRACE("#### Fail : pMap == nullptr ####\n"); return; } if (x1 < 0 || z1 < 0 || x1 >= pMap->GetMapSize() || z1 >= pMap->GetMapSize()) { TRACE("#### RecvUserInOut Fail : [name=%s], x1=%d, z1=%d #####\n", pUser->GetName().c_str(), region_x, region_z); return; } //if (pMap->m_pMap[x1][z1].m_sEvent == 0) return; if (region_x > pMap->GetXRegionMax() || region_z > pMap->GetZRegionMax()) { TRACE("#### GameSocket-RecvUserInOut() Fail : [name=%s], nRX=%d, nRZ=%d #####\n", pUser->GetName().c_str(), region_x, region_z); return; } pUser->m_curx = pUser->m_fWill_x = fX; pUser->m_curz = pUser->m_fWill_z = fZ; // leaving a region if (bType == 2) { pMap->RegionUserRemove(region_x, region_z, uid); } // entering a region else if (pUser->m_sRegionX != region_x || pUser->m_sRegionZ != region_z) { pUser->m_sRegionX = region_x; pUser->m_sRegionZ = region_z; pMap->RegionUserAdd(region_x, region_z, uid); } }
void CUdpSocket::RecvModifyFame( char* pBuf, BYTE command ) { int index = 0, send_index = 0, knightsindex = 0, idlen = 0, vicechief = 0; char send_buff[128]; memset( send_buff, 0x00, 128 ); char finalstr[128]; memset( finalstr, 0x00, 128 ); char userid[MAX_ID_SIZE+1]; memset( userid, 0x00, MAX_ID_SIZE+1 ); CUser* pTUser = NULL; CKnights* pKnights = NULL; knightsindex = GetShort( pBuf, index ); idlen = GetShort( pBuf, index ); GetString( userid, pBuf, idlen, index ); pTUser = m_pMain->GetUserPtr(userid, TYPE_CHARACTER); pKnights = m_pMain->m_KnightsArray.GetData( knightsindex ); switch( command ) { case KNIGHTS_REMOVE: if( pTUser ) { pTUser->m_pUserData->m_bKnights = 0; pTUser->m_pUserData->m_bFame = 0; sprintf( finalstr, "#### %s님이 추방되셨습니다. ####", pTUser->m_pUserData->m_id ); m_pMain->m_KnightsManager.RemoveKnightsUser( knightsindex, pTUser->m_pUserData->m_id ); } else { m_pMain->m_KnightsManager.RemoveKnightsUser( knightsindex, userid ); } break; case KNIGHTS_ADMIT: if( pTUser ) pTUser->m_pUserData->m_bFame = KNIGHT; break; case KNIGHTS_REJECT: if( pTUser ) { pTUser->m_pUserData->m_bKnights = 0; pTUser->m_pUserData->m_bFame = 0; m_pMain->m_KnightsManager.RemoveKnightsUser( knightsindex, pTUser->m_pUserData->m_id ); } break; case KNIGHTS_CHIEF+0x10: if( pTUser ) { pTUser->m_pUserData->m_bFame = CHIEF; m_pMain->m_KnightsManager.ModifyKnightsUser( knightsindex, pTUser->m_pUserData->m_id ); sprintf( finalstr, "#### %s님이 단장으로 임명되셨습니다. ####", pTUser->m_pUserData->m_id ); } break; case KNIGHTS_VICECHIEF+0x10: if( pTUser ) { pTUser->m_pUserData->m_bFame = VICECHIEF; m_pMain->m_KnightsManager.ModifyKnightsUser( knightsindex, pTUser->m_pUserData->m_id ); sprintf( finalstr, "#### %s님이 부단장으로 임명되셨습니다. ####", pTUser->m_pUserData->m_id ); } break; case KNIGHTS_OFFICER+0x10: if( pTUser ) pTUser->m_pUserData->m_bFame = OFFICER; break; case KNIGHTS_PUNISH+0x10: if( pTUser ) pTUser->m_pUserData->m_bFame = PUNISH; break; } if( pTUser ) { //TRACE("UDP - RecvModifyFame - command=%d, nid=%d, name=%s, index=%d, fame=%d\n", command, pTUser->GetSocketID(), pTUser->m_pUserData->m_id, knightsindex, pTUser->m_pUserData->m_bFame); memset( send_buff, 0x00, 128 ); send_index = 0; SetByte( send_buff, WIZ_KNIGHTS_PROCESS, send_index ); SetByte( send_buff, KNIGHTS_MODIFY_FAME, send_index ); SetByte( send_buff, 0x01, send_index ); if( command == KNIGHTS_REMOVE ) { SetShort( send_buff, pTUser->GetSocketID(), send_index ); SetShort( send_buff, pTUser->m_pUserData->m_bKnights, send_index ); SetByte( send_buff, pTUser->m_pUserData->m_bFame, send_index ); m_pMain->Send_Region( send_buff, send_index, pTUser->GetMap(), pTUser->m_RegionX, pTUser->m_RegionZ, NULL, false ); } else { SetShort( send_buff, pTUser->GetSocketID(), send_index ); SetShort( send_buff, pTUser->m_pUserData->m_bKnights, send_index ); SetByte( send_buff, pTUser->m_pUserData->m_bFame, send_index ); pTUser->Send( send_buff, send_index ); } if( command == KNIGHTS_REMOVE ) { memset( send_buff, 0x00, 128 ); send_index = 0; SetByte( send_buff, WIZ_CHAT, send_index ); SetByte( send_buff, KNIGHTS_CHAT, send_index ); SetByte( send_buff, 1, send_index ); SetShort( send_buff, -1, send_index ); SetShort( send_buff, strlen(finalstr), send_index ); SetString( send_buff, finalstr, strlen(finalstr), send_index ); pTUser->Send( send_buff, send_index ); } } memset( send_buff, 0x00, 128 ); send_index = 0; SetByte( send_buff, WIZ_CHAT, send_index ); SetByte( send_buff, KNIGHTS_CHAT, send_index ); SetByte( send_buff, 1, send_index ); SetShort( send_buff, -1, send_index ); SetShort( send_buff, strlen(finalstr), send_index ); SetString( send_buff, finalstr, strlen(finalstr), send_index ); m_pMain->Send_KnightsMember( knightsindex, send_buff, send_index ); }
BOOL CGameSocket::SetUid(float x, float z, int id, int speed) { int x1 = (int)x / TILE_SIZE; int z1 = (int)z / TILE_SIZE; int nRX = (int)x / VIEW_DIST; int nRZ = (int)z / VIEW_DIST; CUser* pUser = m_pMain->GetUserPtr(id); if(pUser == NULL) { TRACE("#### User등록 실패 sid = %d ####\n", id); return FALSE; } MAP* pMap = pUser->GetMap(); if (pMap == NULL) { TRACE("#### User not in valid zone, sid = %d ####\n", id); return FALSE; } if(x1 < 0 || z1 < 0 || x1 > pMap->m_sizeMap.cx || z1 > pMap->m_sizeMap.cy) { TRACE("#### GameSocket ,, SetUid Fail : [nid=%d, name=%s], x1=%d, z1=%d #####\n", id, pUser->m_strUserID, x1, z1); return FALSE; } if(nRX > pMap->GetXRegionMax() || nRZ > pMap->GetZRegionMax()) { TRACE("#### GameSocket , SetUid Fail : [nid=%d, name=%s], nRX=%d, nRZ=%d #####\n", id, pUser->m_strUserID, nRX, nRZ); return FALSE; } // map 이동이 불가능이면 User등록 실패.. // if(pMap->m_pMap[x1][z1].m_sEvent == 0) return FALSE; if(pUser != NULL) { if(pUser->m_bLive == USER_DEAD || pUser->m_sHP <= 0) { if(pUser->m_sHP > 0) { pUser->m_bLive = USER_LIVE; TRACE("##### CGameSocket-SetUid Fail : User가 Heal된 경우.. [id=%s, bLive=%d, hp=%d] ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP); } else { TRACE("##### CGameSocket-SetUid Fail : UserDead [id=%s, bLive=%d, hp=%d] ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP); //Send_UserError(id); return FALSE; } } ///// attack ~ if( speed != 0 ) { pUser->m_curx = pUser->m_fWill_x; pUser->m_curz = pUser->m_fWill_z; pUser->m_fWill_x = x; pUser->m_fWill_z = z; } else { pUser->m_curx = pUser->m_fWill_x = x; pUser->m_curz = pUser->m_fWill_z = z; } /////~ attack //TRACE("GameSocket : SetUid()--> uid = %d, x=%f, z=%f \n", id, x, z); if(pUser->m_sRegionX != nRX || pUser->m_sRegionZ != nRZ) { //TRACE("*** SetUid()-> User(%s, %d)를 Region에 삭제,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, pUser->m_sRegionX, pUser->m_sRegionZ); pMap->RegionUserRemove(pUser->m_sRegionX, pUser->m_sRegionZ, id); pUser->m_sRegionX = nRX; pUser->m_sRegionZ = nRZ; pMap->RegionUserAdd(pUser->m_sRegionX, pUser->m_sRegionZ, id); //TRACE("*** SetUid()-> User(%s, %d)를 Region에 등록,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, nRX, nRZ); } } // dungeon work // if( pUser->m_curZone == 던젼 ) int room = pMap->IsRoomCheck( x, z ); return TRUE; }
void CGameSocket::RecvUserInOut(char* pBuf) { int index = 0; BYTE bType=-1; short uid=-1, len=0; char strName[MAX_ID_SIZE+1]; memset(strName, 0x00, MAX_ID_SIZE+1); float fX=-1, fZ=-1; bType = GetByte( pBuf, index ); uid = GetShort( pBuf, index ); len = GetShort( pBuf, index ); GetString(strName, pBuf, len, index); fX = Getfloat(pBuf, index); fZ = Getfloat(pBuf, index); if(fX < 0 || fZ < 0) { TRACE("Error:: RecvUserInOut(),, uid = %d, fX=%.2f, fZ=%.2f\n", uid, fX, fZ); return; } // TRACE("RecvUserInOut(),, uid = %d\n", uid); int region_x = 0, region_z=0; int x1 = (int)fX / TILE_SIZE; int z1 = (int)fZ / TILE_SIZE; region_x = (int)fX / VIEW_DIST; region_z = (int)fZ / VIEW_DIST; // 수정할것,,, : 지금 존 번호를 0으로 했는데.. 유저의 존 정보의 번호를 읽어야,, 함,, MAP* pMap = NULL; //m_pMain->g_arZone[pUser->m_curZone]; CUser* pUser = m_pMain->GetUserPtr(uid); // TRACE("^^& RecvUserInOut( type=%d )-> User(%s, %d),, zone=%d, index=%d, region_x=%d, y=%d\n", bType, pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); if(pUser != NULL) { // TRACE("##### Fail : ^^& RecvUserInOut() [name = %s]. state=%d, hp=%d\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP); BOOL bFlag = FALSE; if(pUser->m_bLive == USER_DEAD || pUser->m_sHP <= 0) { if(pUser->m_sHP > 0) { pUser->m_bLive = TRUE; TRACE("##### CGameSocket-RecvUserInOut Fail : UserHeal [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP, fX, fZ); } else { TRACE("##### CGameSocket-RecvUserInOut Fail : UserDead [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP, fX, fZ); // 죽은 유저이므로 게임서버에 죽은 처리를 한다... //Send_UserError(uid); //return; } } pMap = pUser->GetMap(); if(pMap == NULL) { TRACE("#### Fail : pMap == NULL ####\n"); return; } if(x1 < 0 || z1 < 0 || x1 > pMap->m_sizeMap.cx || z1 > pMap->m_sizeMap.cy) { TRACE("#### RecvUserInOut Fail : [name=%s], x1=%d, z1=%d #####\n", pUser->m_strUserID, region_x, region_z); return; } // map 이동이 불가능이면 User등록 실패.. //if(pMap->m_pMap[x1][z1].m_sEvent == 0) return; if(region_x > pMap->GetXRegionMax() || region_z > pMap->GetZRegionMax()) { TRACE("#### GameSocket-RecvUserInOut() Fail : [name=%s], nRX=%d, nRZ=%d #####\n", pUser->m_strUserID, region_x, region_z); return; } //strcpy(pUser->m_strUserID, strName); pUser->m_curx = pUser->m_fWill_x = fX; pUser->m_curz = pUser->m_fWill_z = fZ; //bFlag = pUser->IsOpIDCheck(strName); //if(bFlag) pUser->m_byIsOP = 1; if(bType == 2) { // region out // 기존의 region정보에서 User의 정보 삭제.. pMap->RegionUserRemove(region_x, region_z, uid); //TRACE("^^& RecvUserInOut()-> User(%s, %d)를 Region에서 삭제..,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); } else { // region in if(pUser->m_sRegionX != region_x || pUser->m_sRegionZ != region_z) { pUser->m_sRegionX = region_x; pUser->m_sRegionZ = region_z; pMap->RegionUserAdd(region_x, region_z, uid); //TRACE("^^& RecvUserInOut()-> User(%s, %d)를 Region에 등록,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); } } } }
void CGameSocket::RecvUserInOut(Packet & pkt) { std::string strUserID; uint8 bType; uint16 uid; float fX, fZ; pkt.SByte(); pkt >> bType >> uid >> strUserID >> fX >> fZ; if (fX < 0 || fZ < 0) { TRACE("Error:: RecvUserInOut(),, uid = %d, fX=%.2f, fZ=%.2f\n", uid, fX, fZ); return; } int region_x = 0, region_z=0; int x1 = (int)fX / TILE_SIZE; int z1 = (int)fZ / TILE_SIZE; region_x = (int)fX / VIEW_DIST; region_z = (int)fZ / VIEW_DIST; // 수정할것,,, : 지금 존 번호를 0으로 했는데.. 유저의 존 정보의 번호를 읽어야,, 함,, MAP* pMap = NULL; //g_pMain->g_arZone[pUser->m_curZone]; CUser* pUser = g_pMain->GetUserPtr(uid); // TRACE("^^& RecvUserInOut( type=%d )-> User(%s, %d),, zone=%d, index=%d, region_x=%d, y=%d\n", bType, pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); if(pUser != NULL) { // TRACE("##### Fail : ^^& RecvUserInOut() [name = %s]. state=%d, hp=%d\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP); BOOL bFlag = FALSE; if(pUser->m_bLive == USER_DEAD || pUser->m_sHP <= 0) { if(pUser->m_sHP > 0) { pUser->m_bLive = TRUE; TRACE("##### CGameSocket-RecvUserInOut Fail : UserHeal [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP, fX, fZ); } else { TRACE("##### CGameSocket-RecvUserInOut Fail : UserDead [id=%s, bLive=%d, hp=%d], fX=%.2f, fZ=%.2f ######\n", pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP, fX, fZ); // 죽은 유저이므로 게임서버에 죽은 처리를 한다... //Send_UserError(uid); //return; } } pMap = pUser->GetMap(); if(pMap == NULL) { TRACE("#### Fail : pMap == NULL ####\n"); return; } if(x1 < 0 || z1 < 0 || x1 > pMap->m_sizeMap.cx || z1 > pMap->m_sizeMap.cy) { TRACE("#### RecvUserInOut Fail : [name=%s], x1=%d, z1=%d #####\n", pUser->m_strUserID, region_x, region_z); return; } // map 이동이 불가능이면 User등록 실패.. //if(pMap->m_pMap[x1][z1].m_sEvent == 0) return; if(region_x > pMap->GetXRegionMax() || region_z > pMap->GetZRegionMax()) { TRACE("#### GameSocket-RecvUserInOut() Fail : [name=%s], nRX=%d, nRZ=%d #####\n", pUser->m_strUserID, region_x, region_z); return; } //strcpy(pUser->m_strUserID, strName); pUser->m_curx = pUser->m_fWill_x = fX; pUser->m_curz = pUser->m_fWill_z = fZ; if(bType == 2) { // region out // 기존의 region정보에서 User의 정보 삭제.. pMap->RegionUserRemove(region_x, region_z, uid); //TRACE("^^& RecvUserInOut()-> User(%s, %d)를 Region에서 삭제..,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); } else { // region in if(pUser->m_sRegionX != region_x || pUser->m_sRegionZ != region_z) { pUser->m_sRegionX = region_x; pUser->m_sRegionZ = region_z; pMap->RegionUserAdd(region_x, region_z, uid); //TRACE("^^& RecvUserInOut()-> User(%s, %d)를 Region에 등록,, zone=%d, index=%d, region_x=%d, y=%d\n", pUser->m_strUserID, pUser->m_iUserId, pUser->m_curZone, pUser->m_sZoneIndex, region_x, region_z); } } } }
void CAISocket::RecvMagicAttackResult(char* pBuf) { int index = 0, send_index = 1, sid = -1, tid = -1, magicid=0; BYTE byCommand; short data0, data1, data2, data3, data4, data5; CNpc* pNpc = NULL; CUser* pUser = NULL; char send_buff[1024]; //byType = GetByte(pBuf,index); // who ( 1:mon->user 2:mon->mon ) //byAttackType = GetByte(pBuf,index); // attack type ( 1:long attack, 2:magic attack byCommand = GetByte(pBuf,index); // magic type ( 1:casting, 2:flying, 3:effecting, 4:fail ) magicid = GetDWORD(pBuf,index); sid = GetShort(pBuf,index); tid = GetShort(pBuf,index); data0 = GetShort(pBuf,index); data1 = GetShort(pBuf,index); data2 = GetShort(pBuf,index); data3 = GetShort(pBuf,index); data4 = GetShort(pBuf,index); data5 = GetShort(pBuf,index); SetByte( send_buff, byCommand, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, sid, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data0, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, data2, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, data4, send_index ); SetShort( send_buff, data5, send_index ); if(byCommand == 0x01) { // casting pNpc = m_pMain->m_arNpcArray.GetData(sid); if(!pNpc) return; index = 0; SetByte( send_buff, WIZ_MAGIC_PROCESS, index ); m_pMain->Send_Region(send_buff, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); } else if(byCommand == 0x03) { // effecting //pNpc = m_pMain->m_arNpcArray.GetData(tid); //if(!pNpc) return; if( sid >= USER_BAND && sid < NPC_BAND) { pUser = m_pMain->GetUserPtr(sid); if (pUser == NULL || pUser->isDead()) return; index = 0; SetByte( send_buff, WIZ_MAGIC_PROCESS, index ); m_pMain->Send_Region(send_buff, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ, NULL, false); } else if(sid >= NPC_BAND) { if(tid >= NPC_BAND) { pNpc = m_pMain->m_arNpcArray.GetData(tid); if(!pNpc) return; index = 0; SetByte( send_buff, WIZ_MAGIC_PROCESS, index ); m_pMain->Send_Region(send_buff, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); return; } send_index = 0; SetByte( send_buff, byCommand, send_index ); SetDWORD( send_buff, magicid, send_index ); SetShort( send_buff, sid, send_index ); SetShort( send_buff, tid, send_index ); SetShort( send_buff, data0, send_index ); SetShort( send_buff, data1, send_index ); SetShort( send_buff, data2, send_index ); SetShort( send_buff, data3, send_index ); SetShort( send_buff, data4, send_index ); SetShort( send_buff, data5, send_index ); m_MagicProcess.MagicPacket(send_buff, send_index); } } }
void CAISocket::RecvNpcAttack(char* pBuf) { int index = 0, send_index = 0, sid = -1, tid = -1, nHP = 0, temp_damage = 0; BYTE type, result, byAttackType = 0; float fDir=0.0f; short damage = 0; CNpc* pNpc = NULL, *pMon = NULL; CUser* pUser = NULL; char pOutBuf[1024]; _OBJECT_EVENT* pEvent = NULL; type = GetByte(pBuf,index); result = GetByte(pBuf,index); sid = GetShort(pBuf,index); tid = GetShort(pBuf,index); damage = GetShort(pBuf,index); nHP = GetDWORD(pBuf,index); byAttackType = GetByte(pBuf, index); //TRACE("CAISocket-RecvNpcAttack : sid=%s, tid=%d, zone_num=%d\n", sid, tid, m_iZoneNum); if(type == 0x01) // user attack -> npc { pNpc = m_pMain->m_arNpcArray.GetData(tid); if(!pNpc) return; pNpc->m_iHP -= damage; if( pNpc->m_iHP < 0 ) pNpc->m_iHP = 0; if(result == 0x04) { // 마법으로 죽는경우 SetByte( pOutBuf, WIZ_DEAD, send_index ); SetShort( pOutBuf, tid, send_index ); m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); } else { SetByte(pOutBuf, WIZ_ATTACK, send_index); SetByte( pOutBuf, byAttackType, send_index ); // 직접:1, 마법:2, 지속마법:3 //if(result == 0x04) // 마법으로 죽는경우 // SetByte( pOutBuf, 0x02, send_index ); //else // 단순공격으로 죽는경우 SetByte( pOutBuf, result, send_index ); SetShort( pOutBuf, sid, send_index ); SetShort( pOutBuf, tid, send_index ); m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); } pUser = m_pMain->GetUserPtr(sid); if (pUser != NULL) { pUser->SendTargetHP( 0, tid, -damage ); if( byAttackType != MAGIC_ATTACK && byAttackType != DURATION_ATTACK) { pUser->ItemWoreOut(ATTACK, damage); // LEFT HAND!!! by Yookozuna temp_damage = damage * pUser->m_bMagicTypeLeftHand / 100 ; switch (pUser->m_bMagicTypeLeftHand) { // LEFT HAND!!! case ITEM_TYPE_HP_DRAIN : // HP Drain pUser->HpChange(temp_damage, 0); break; case ITEM_TYPE_MP_DRAIN : // MP Drain pUser->MSpChange(temp_damage); break; } temp_damage = 0; // reset data; // RIGHT HAND!!! by Yookozuna temp_damage = damage * pUser->m_bMagicTypeRightHand / 100 ; switch (pUser->m_bMagicTypeRightHand) { // LEFT HAND!!! case ITEM_TYPE_HP_DRAIN : // HP Drain pUser->HpChange(temp_damage, 0); break; case ITEM_TYPE_MP_DRAIN : // MP Drain pUser->MSpChange(temp_damage); break; } // } } if(result == 0x02 || result == 0x04) // npc dead { pNpc->GetMap()->RegionNpcRemove(pNpc->m_sRegion_X, pNpc->m_sRegion_Z, tid); // TRACE("--- Npc Dead : Npc를 Region에서 삭제처리.. ,, region_x=%d, y=%d\n", pNpc->m_sRegion_X, pNpc->m_sRegion_Z); pNpc->m_sRegion_X = 0; pNpc->m_sRegion_Z = 0; pNpc->m_NpcState = NPC_DEAD; if( pNpc->m_byObjectType == SPECIAL_OBJECT ) { pEvent = pNpc->GetMap()->GetObjectEvent( pNpc->m_sSid ); if( pEvent ) pEvent->byLife = 0; } if (pNpc->m_tNpcType == 2 && pUser != NULL) // EXP pUser->GiveItem(900001000, 1); } } else if(type == 0x02) // npc attack -> user { pNpc = m_pMain->m_arNpcArray.GetData(sid); if(!pNpc) return; //TRACE("CAISocket-RecvNpcAttack 222 : sid=%s, tid=%d, zone_num=%d\n", sid, tid, m_iZoneNum); if( tid >= USER_BAND && tid < NPC_BAND) { pUser = m_pMain->GetUserPtr(tid); if(pUser == NULL) return; // sungyong 2002. 02.04 /* if( sHP <= 0 && pUser->m_pUserData->m_sHp > 0 ) { TRACE("Npc Attack : id=%s, result=%d, AI_HP=%d, GM_HP=%d\n", pUser->m_pUserData->m_id, result, sHP, pUser->m_pUserData->m_sHp); if(result == 0x02) pUser->HpChange(-1000, 1); } else pUser->HpChange(-damage, 1); */ // ~sungyong 2002. 02.04 if( pUser->m_MagicProcess.m_bMagicState == CASTING ) pUser->m_MagicProcess.IsAvailable( 0, -1, -1, MAGIC_EFFECTING ,0,0,0 ); pUser->HpChange(-damage, 1, true); pUser->ItemWoreOut(DEFENCE, damage); SetByte(pOutBuf, WIZ_ATTACK, send_index); SetByte( pOutBuf, byAttackType, send_index ); if(result == 0x03) SetByte( pOutBuf, 0x00, send_index ); else SetByte( pOutBuf, result, send_index ); SetShort( pOutBuf, sid, send_index ); SetShort( pOutBuf, tid, send_index ); m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); // TRACE("RecvNpcAttack : id=%s, result=%d, AI_HP=%d, GM_HP=%d\n", pUser->m_pUserData->m_id, result, sHP, pUser->m_pUserData->m_sHp); //TRACE("RecvNpcAttack ==> sid = %d, tid = %d, result = %d\n", sid, tid, result); if(result == 0x02) { // user dead if (pUser->m_bResHpType == USER_DEAD) return; // 유저에게는 바로 데드 패킷을 날림... (한 번 더 보냄, 유령을 없애기 위해서) send_index = 0; SetByte(pOutBuf, WIZ_DEAD, send_index); SetShort(pOutBuf, pUser->GetSocketID(), send_index); m_pMain->Send_Region(pOutBuf, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ); pUser->m_bResHpType = USER_DEAD; DEBUG_LOG("*** User Dead, id=%s, result=%d, AI_HP=%d, GM_HP=%d, x=%d, z=%d", pUser->m_pUserData->m_id, result, nHP, pUser->m_pUserData->m_sHp, (int)pUser->m_pUserData->m_curx, (int)pUser->m_pUserData->m_curz); send_index = 0; if( pUser->m_pUserData->m_bFame == COMMAND_CAPTAIN ) { // 지휘권한이 있는 유저가 죽는다면,, 지휘 권한 박탈 pUser->m_pUserData->m_bFame = CHIEF; SetByte( pOutBuf, WIZ_AUTHORITY_CHANGE, send_index ); SetByte( pOutBuf, COMMAND_AUTHORITY, send_index ); SetShort( pOutBuf, pUser->GetSocketID(), send_index ); SetByte( pOutBuf, pUser->m_pUserData->m_bFame, send_index ); m_pMain->Send_Region( pOutBuf, send_index, pUser->GetMap(), pUser->m_RegionX, pUser->m_RegionZ ); // sungyong tw pUser->Send( pOutBuf, send_index ); // ~sungyong tw TRACE("---> AISocket->RecvNpcAttack() Dead Captain Deprive - %s\n", pUser->m_pUserData->m_id); if( pUser->m_pUserData->m_bNation == KARUS ) m_pMain->Announcement( KARUS_CAPTAIN_DEPRIVE_NOTIFY, KARUS ); else if( pUser->m_pUserData->m_bNation == ELMORAD ) m_pMain->Announcement( ELMORAD_CAPTAIN_DEPRIVE_NOTIFY, ELMORAD ); } if(pNpc->m_tNpcType == NPC_PATROL_GUARD) { // 경비병에게 죽는 경우라면.. pUser->ExpChange( -pUser->m_iMaxExp/100 ); //TRACE("RecvNpcAttack : 경험치를 1%깍기 id = %s\n", pUser->m_pUserData->m_id); } else { // if( pUser->m_pUserData->m_bZone != pUser->m_pUserData->m_bNation && pUser->m_pUserData->m_bZone < 3) { pUser->ExpChange(-pUser->m_iMaxExp / 100); //TRACE("정말로 1%만 깍였다니까요 ㅠ.ㅠ"); } // else { pUser->ExpChange( -pUser->m_iMaxExp/20 ); } //TRACE("RecvNpcAttack : 경험치를 5%깍기 id = %s\n", pUser->m_pUserData->m_id); } } } else if(tid >= NPC_BAND) // npc attack -> monster { pMon = m_pMain->m_arNpcArray.GetData(tid); if(!pMon) return; pMon->m_iHP -= damage; if( pMon->m_iHP < 0 ) pMon->m_iHP = 0; send_index = 0; SetByte(pOutBuf, WIZ_ATTACK, send_index); SetByte( pOutBuf, byAttackType, send_index ); SetByte( pOutBuf, result, send_index ); SetShort( pOutBuf, sid, send_index ); SetShort( pOutBuf, tid, send_index ); if(result == 0x02) { // npc dead pNpc->GetMap()->RegionNpcRemove(pMon->m_sRegion_X, pMon->m_sRegion_Z, tid); // TRACE("--- Npc Dead : Npc를 Region에서 삭제처리.. ,, region_x=%d, y=%d\n", pMon->m_sRegion_X, pMon->m_sRegion_Z); pMon->m_sRegion_X = 0; pMon->m_sRegion_Z = 0; pMon->m_NpcState = NPC_DEAD; if( pNpc->m_byObjectType == SPECIAL_OBJECT ) { pEvent = pNpc->GetMap()->GetObjectEvent( pMon->m_sSid ); if( pEvent ) pEvent->byLife = 0; } } m_pMain->Send_Region(pOutBuf, send_index, pNpc->GetMap(), pNpc->m_sRegion_X, pNpc->m_sRegion_Z, NULL, false); } } }