#ifndef _CHAR_MOVE_PACKET_H_ #define _CHAR_MOVE_PACKET_H_ // CharMovePacket.h #include #include #include #include #include #pragma pack(1) class CNetworkPos { private: static const float ms_fToRadian; static const float ms_fToAngle; static const float ms_fPositionDetail; static const float ms_fVelocityDetail; unsigned short m_usXPos; unsigned short m_usYPos; unsigned short m_usZPos; unsigned char m_cDirection; // Á¤¹Ðµµ - 0~180 (1¿¡ 2µµ) unsigned char m_cVelocity; // ¼Óµµ/ÇÁ·¹ÀÓ(1ÇÁ·¹ÀÓ¿¡ ¿òÁ÷ÀÏ ¼ö ÀÖ´Â ÃÖ´ë°Å¸®.) // ¼Óµµ = ÃÊ´ç À̵¿°Å¸® = 1~5¹ÌÅÍ. // ÇÁ·¹ÀÓ = ÃÖ´ë 60ÇÁ·¹ÀÓ. // ÃÖ´ë °¡´ÉÇÑ ¼Óµµ/ÇÁ·¹ÀÓ * 1000 = 0 ~ 255 // ¼Óµµ/ÇÁ·¹ÀÓ = 0 ~ 0.255¹ÌÅÍ // TODO : maximum 10meter/sec public: CNetworkPos() : m_usXPos(0), m_usYPos(0), m_usZPos(0), m_cDirection(0), m_cVelocity(0) { } CNetworkPos(float fXPos, float fYPos, float fZPos, float fDir = 0.0f, float fVel = 0.0f) { Initialize(fXPos, fYPos, fZPos, fDir, fVel); } CNetworkPos(const POS& pos, float fDir = 0.0f, float fVel = 0.0f) { Initialize(pos.fPointX, pos.fPointY, pos.fPointZ, fDir, fVel); } void Initialize(float fXPos, float fYPos, float fZPos, float fDir, float fVel); float GetXPos() const { return static_cast(m_usXPos) / ms_fPositionDetail; } float GetYPos() const { return static_cast(m_usYPos) / ms_fPositionDetail; } float GetZPos() const { return static_cast(m_usZPos) / ms_fPositionDetail; } float GetDirection() const { return static_cast(m_cDirection) * 2 * ms_fToRadian; } float GetVelocity() const { return static_cast(m_cVelocity) / ms_fVelocityDetail; } float GetSquaredRange(const CNetworkPos& lhs) const { const float xDiff = GetXPos() - lhs.GetXPos(); const float yDiff = GetYPos() - lhs.GetYPos(); const float zDiff = GetZPos() - lhs.GetZPos(); return (xDiff * xDiff) + (yDiff * yDiff) + (zDiff * zDiff); } float GetRange(const CNetworkPos& lhs) const { return std::sqrtf(GetSquaredRange(lhs)); } inline bool operator == (const CNetworkPos& lhs) { return (m_usXPos == lhs.m_usXPos && m_usYPos == lhs.m_usYPos && m_usZPos == lhs.m_usZPos && m_cDirection == lhs.m_cDirection && m_cVelocity == lhs.m_cVelocity); } inline bool operator != (const CNetworkPos& lhs) { return !(*this == lhs); } }; inline void CNetworkPos::Initialize(float fXPos, float fYPos, float fZPos, float fDir, float fVel) { float fbuf; fbuf = fXPos * ms_fPositionDetail; m_usXPos = static_cast(fbuf); fbuf = fYPos * ms_fPositionDetail; m_usYPos = static_cast(fbuf); fbuf = fZPos * ms_fPositionDetail; m_usZPos = static_cast(fbuf); /* // floatÀÇ ¼Ò¼ýÁ¡ ¿¬»ê¿¡ ¿ÀÂ÷°¡ ÀÖ¾î ¹Ý¿Ã¸²ÇÕ´Ï´Ù. m_usXPos = static_cast(fXPos * ms_fPositionDetail + 0.5f); m_usYPos = static_cast(fYPos * ms_fPositionDetail + 0.5f); m_usZPos = static_cast(fZPos * ms_fPositionDetail + 0.5f); */ float fAngle = fDir * ms_fToAngle; while (360 <= fAngle) { fAngle -= 360; } m_cDirection = static_cast(fAngle/2); unsigned int nVelocity = static_cast(fVel * ms_fVelocityDetail); if(255 < nVelocity) { nVelocity = 255; } m_cVelocity = static_cast(nVelocity); } // ij¸¯ÅÍ À̵¿ ÆÐŶ Ex (CharMove, TCP) typedef struct PktMVEx* LPPktMVEx; struct PktMVEx : public PktBase { // CID´Â PktBaseÀÇ dwServerInfo¿¡ ´ã´Â´Ù. CNetworkPos m_NetworkPos; unsigned char m_cUAct; unsigned char m_cLAct; }; /* Deplicated // ij¸¯ÅÍ À̵¿ ÆÐŶ (CharMove, UDP) typedef struct PktMV* LPPktMV; struct PktMV : public PktBase { POS m_Position; // ij¸¯ÅÍ À§Ä¡ float m_fDir; // ij¸¯ÅÍ ¹æÇâ unsigned long m_dwCharID; // ij¸¯ÅÍ ID unsigned long m_dwChantEf; // Chant Effect unsigned long m_dwEnchantEf; // Enchant Effect unsigned short m_wUAct; // ¾×¼Ç ¹øÈ£ unsigned short m_wLAct; // ¾×¼Ç ¹øÈ£ unsigned char m_wLevel; // ij¸¯ÅÍ ·¹º§ }; // ij¸¯ÅÍ À̵¿ ¾÷µ¥ÀÌÆ® ÆÐŶ ( Char Move Update ) typedef struct PktMU* LPPktMU; struct PktMU : public PktBase { POS m_Position; // À§Ä¡ float m_fDir; // ¹æÇâ unsigned long m_dwTick; // Ŭ¶óÀÌ¾ðÆ® Æ½ bool m_bSitMode; // ¾É±â (true = ¾É¾Æ ÀÖÀ½.) }; // ij¸¯ÅÍ À̵¿ ¾÷µ¥ÀÌÆ® ÆÐŶ Ack ( Char Move Update ) typedef struct PktMUAck* LPPktMUAck; struct PktMUAck : public PktBase { unsigned long m_dwTick; // Ŭ¶óÀÌ¾ðÆ® Æ½ (ó¸® ½Ã°£ ÆÛÆ÷ ÃøÁ¤) unsigned char m_cFlag; // - Ç÷¡±× (0 = À̵¿, 1 = ¼¿À̵¿) }; */ // ¼Òȯ typedef struct PktSummon* LPPktSummon; struct PktSummon : public PktBase { unsigned long m_dwCharID; // ij¸¯ÅÍ ID unsigned long m_dwTargetID; // ´ë»ó ID CNetworkPos m_NetworkPos; // ³×Æ®¿öÅ© À§Ä¡ }; // ¸ó½ºÅÍ ¿òÁ÷ÀÓ ( Monster Move ) typedef struct PktMM* LPPktMM; struct PktMM : public PktBase { unsigned long m_dwMonID; // ¸ó½ºÅÍ ¾ÆÀ̵ð CNetworkPos m_NetworkPos; // ³×Æ®¿öÅ© À§Ä¡ unsigned char m_cAct; // ¸ó½ºÅÍ Çൿ unsigned char m_cAniNum; // ¸ó½ºÅÍ À̵¿ Ƚ¼ö }; namespace CellCommand { enum Type { CELL_MOVE = 0, CELL_LOGIN = 1, RESPAWN = 2 }; }; // ij¸¯ÅÍ ¼¿ ·Î±×ÀÎ ÆÐŶ (Char Cell Login) typedef struct PktCCLi* LPPktCCLi; struct PktCCLi : public PktBase { unsigned char m_cCmd; // see namespace CellCommand // ÆÐŶ µÚ¿¡ BroadcastInfo::CharInfo::SLoginPhase°¡ ºÙ¾î ¿Â´Ù. }; // ij¸¯ÅÍ ¼¿ ·Î±×¾Æ¿ô ÆÐŶ ( Char Cell Logout ) typedef struct PktCCLo* LPPktCCLo; struct PktCCLo : public PktBase { unsigned long m_dwCharID; unsigned char m_cCmd; // see namespace CellCommand }; // ¼¿ ºê·Îµå ij½ºÆÃ + Address±¸Á¶Ã¼ typedef struct PktCB PktCB, *LPPktCB; struct PktCB : public PktBase { unsigned char m_cCharacterPhase; // ¼¿ ºê·Îµåij½ºÆÃ Phase(ij¸¯ÅÍ). unsigned short m_usBufferSize; // ¼¿ ¹öÆÛ Å©±â }; #pragma pack() #endif