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); } }
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); } } } }