void CUser::MoveProcess(Packet & pkt) { ASSERT(GetMap() != nullptr); if (m_bWarp || isDead()) return; uint16 will_x, will_z, will_y; int16 speed=0; float real_x, real_z, real_y; uint8 echo; pkt >> will_x >> will_z >> will_y >> speed >> echo; real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f; if (!isGM()) { // TO-DO: Handle proper speed checks against server-side amounts. // We should also avoid relying on what the client has sent us. if (speed > 200) // What is the signifance of this number? Considering 90 is light feet... // We shouldn't be using magic numbers at all here. { Disconnect(); return; } } if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) return; if (m_oldx != GetX() || m_oldz != GetZ()) { m_oldx = GetX(); m_oldy = GetY(); m_oldz = GetZ(); } // TO-DO: Ensure this is checked properly to prevent speedhacking SetPosition(real_x, real_y, real_z); if (RegisterRegion()) { g_pMain->RegionNpcInfoForMe(this); g_pMain->RegionUserInOutForMe(this); g_pMain->MerchantUserInOutForMe(this); } if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE) CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE); Packet result(WIZ_MOVE); result << GetSocketID() << will_x << will_z << will_y << speed << echo; SendToRegion(&result); GetMap()->CheckEvent(real_x, real_z, this); result.Initialize(AG_USER_MOVE); result << GetSocketID() << m_curx << m_curz << m_cury << speed; Send_AIServer(&result); }
void CUser::MoveProcess(char *pBuf ) { ASSERT(GetMap() != NULL); if( m_bWarp ) return; int index = 0, region = 0; WORD will_x, will_z; short will_y, speed=0; float real_x, real_z, real_y; BYTE echo; will_x = GetShort( pBuf, index ); will_z = GetShort( pBuf, index ); will_y = GetShort( pBuf, index ); speed = GetShort( pBuf, index ); echo = GetByte( pBuf, index ); real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f; if (GetMap()->IsValidPosition(real_x, real_z, real_y) == FALSE) return; if (isDead() && speed != 0) TRACE("### MoveProcess Fail : name=%s(%d), m_bResHpType=%d, hp=%d, speed=%d, x=%d, z=%d ###\n", m_pUserData->m_id, m_Sid, m_bResHpType, m_pUserData->m_sHp, speed, (int)m_pUserData->m_curx, (int)m_pUserData->m_curz); if( speed != 0 ) { m_pUserData->m_curx = m_fWill_x; // ????? ??? ?????g?? ??????g?? ????... m_pUserData->m_curz = m_fWill_z; m_pUserData->m_cury = m_fWill_y; m_fWill_x = will_x/10.0f; // ?????g?? ???.... m_fWill_z = will_z/10.0f; m_fWill_y = will_y/10.0f; } else { m_pUserData->m_curx = m_fWill_x = will_x/10.0f; // ?????g == ???? ??g... m_pUserData->m_curz = m_fWill_z = will_z/10.0f; m_pUserData->m_cury = m_fWill_y = will_y/10.0f; } Packet result(WIZ_MOVE); result << uint16(m_Sid) << will_x << will_z << will_y << speed << echo; RegisterRegion(); m_pMain->Send_Region( &result, GetMap(), m_RegionX, m_RegionZ ); GetMap()->CheckEvent( real_x, real_z, this ); result.Initialize(AG_USER_MOVE); result << uint16(m_Sid) << m_fWill_x << m_fWill_z << m_fWill_y << speed; m_pMain->Send_AIServer(&result); }
/** * @brief Sends the movement packet for the NPC. * * @param fPosX The position x coordinate. * @param fPosY The position y coordinate. * @param fPosZ The position z coordinate. * @param fSpeed The speed. */ void CNpc::MoveResult(float fPosX, float fPosY, float fPosZ, float fSpeed) { Packet result(WIZ_NPC_MOVE); SetPosition(fPosX, fPosY, fPosZ); RegisterRegion(); result << GetID() << GetSPosX() << GetSPosZ() << GetSPosY() << uint16(fSpeed * 10); SendToRegion(&result); }
void CUser::MoveProcess(Packet & pkt) { ASSERT(GetMap() != nullptr); if (m_bWarp || isDead()) return; uint16 will_x, will_z, will_y; int16 speed=0; float real_x, real_z, real_y; uint8 echo; pkt >> will_x >> will_z >> will_y >> speed >> echo; real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f; m_sSpeed = speed; SpeedHackUser(); if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) return; if (m_oldx != GetX() || m_oldz != GetZ()) { m_oldx = GetX(); m_oldy = GetY(); m_oldz = GetZ(); } // TODO: Ensure this is checked properly to prevent speedhacking SetPosition(real_x, real_y, real_z); if (RegisterRegion()) { g_pMain->RegionNpcInfoForMe(this); g_pMain->RegionUserInOutForMe(this); g_pMain->MerchantUserInOutForMe(this); } if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE) CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE); Packet result(WIZ_MOVE); result << GetSocketID() << will_x << will_z << will_y << speed << echo; SendToRegion(&result); GetMap()->CheckEvent(real_x, real_z, this); result.Initialize(AG_USER_MOVE); result << GetSocketID() << m_curx << m_curz << m_cury << speed; Send_AIServer(&result); }
void CUser::MoveProcess(Packet & pkt) { ASSERT(GetMap() != NULL); if (m_bWarp || isDead()) return; uint16 will_x, will_z, will_y, speed=0; float real_x, real_z, real_y; uint8 echo; pkt >> will_x >> will_z >> will_y >> speed >> echo; real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f; if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) return; // TO-DO: Ensure this is checked properly to prevent speedhacking m_curx = real_x; m_curz = real_z; m_cury = real_y; if (RegisterRegion()) { g_pMain->RegionNpcInfoForMe(this); g_pMain->RegionUserInOutForMe(this); g_pMain->MerchantUserInOutForMe(this); } if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE) StateChangeServerDirect(7, INVIS_NONE); Packet result(WIZ_MOVE); result << GetSocketID() << will_x << will_z << will_y << speed << echo; SendToRegion(&result); GetMap()->CheckEvent(real_x, real_z, this); result.Initialize(AG_USER_MOVE); result << GetSocketID() << m_curx << m_curz << m_cury << speed; Send_AIServer(&result); }
void CNpc::MoveResult(float xpos, float ypos, float zpos, float speed) { m_fCurX = xpos; m_fCurZ = zpos; m_fCurY = ypos; RegisterRegion(); int send_index = 0; char pOutBuf[1024]; memset(pOutBuf, 0, 1024); SetByte(pOutBuf, WIZ_NPC_MOVE, send_index); SetShort(pOutBuf, m_sNid, send_index); SetShort(pOutBuf, (WORD)m_fCurX*10, send_index); SetShort(pOutBuf, (WORD)m_fCurZ*10, send_index); SetShort(pOutBuf, (short)m_fCurY*10, send_index); SetShort(pOutBuf, (short)speed*10, send_index); m_pMain->Send_Region(pOutBuf, send_index, GetMap(), m_sRegion_X, m_sRegion_Z, NULL, false ); }
void CUser::MoveProcess(char *pBuf ) { ASSERT(GetMap() != NULL); if( m_bWarp ) return; int index = 0, send_index = 0, region = 0; WORD will_x, will_z; short will_y, speed=0; float real_x, real_z, real_y; BYTE echo; char send_buff[32]; will_x = GetShort( pBuf, index ); will_z = GetShort( pBuf, index ); will_y = GetShort( pBuf, index ); speed = GetShort( pBuf, index ); echo = GetByte( pBuf, index ); real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f; if (GetMap()->IsValidPosition(real_x, real_z, real_y) == FALSE) return; if (isDead() && speed != 0) TRACE("### MoveProcess Fail : name=%s(%d), m_bResHpType=%d, hp=%d, speed=%d, x=%d, z=%d ###\n", m_pUserData->m_id, m_Sid, m_bResHpType, m_pUserData->m_sHp, speed, (int)m_pUserData->m_curx, (int)m_pUserData->m_curz); if( speed != 0 ) { m_pUserData->m_curx = m_fWill_x; // ????? ??? ?????g?? ??????g?? ????... m_pUserData->m_curz = m_fWill_z; m_pUserData->m_cury = m_fWill_y; m_fWill_x = will_x/10.0f; // ?????g?? ???.... m_fWill_z = will_z/10.0f; m_fWill_y = will_y/10.0f; } else { m_pUserData->m_curx = m_fWill_x = will_x/10.0f; // ?????g == ???? ??g... m_pUserData->m_curz = m_fWill_z = will_z/10.0f; m_pUserData->m_cury = m_fWill_y = will_y/10.0f; } SetByte( send_buff, WIZ_MOVE, send_index ); SetShort( send_buff, m_Sid, send_index ); SetShort( send_buff, will_x, send_index ); SetShort( send_buff, will_z, send_index ); SetShort( send_buff, will_y, send_index ); SetShort( send_buff, speed, send_index ); SetByte( send_buff, echo, send_index ); RegisterRegion(); m_pMain->Send_Region( send_buff, send_index, GetMap(), m_RegionX, m_RegionZ, NULL, false ); GetMap()->CheckEvent( real_x, real_z, this ); send_index = 0; SetByte( send_buff, AG_USER_MOVE, send_index ); SetShort( send_buff, m_Sid, send_index ); Setfloat( send_buff, m_fWill_x, send_index ); Setfloat( send_buff, m_fWill_z, send_index ); Setfloat( send_buff, m_fWill_y, send_index ); SetShort( send_buff, speed, send_index ); m_pMain->Send_AIServer(send_buff, send_index); }