Msg.h
00001 #ifndef _MSG_H 00002 #define _MSG_H 00003 00004 #include "MPacket.h" 00005 00006 00007 #define MSGID_REPLYCONNECT 10 00008 #define MSGID_COMMAND 100 00009 00010 00011 #pragma pack(1) 00012 00013 struct MReplyConnectMsg : public MPacketHeader 00014 { 00015 unsigned int nHostHigh; 00016 unsigned int nHostLow; 00017 unsigned int nAllocHigh; 00018 unsigned int nAllocLow; 00019 }; 00020 00021 struct MCommandMsg : public MPacketHeader 00022 { 00023 char Buffer[1]; 00024 }; 00025 00026 #pragma pack() 00027 00028 00029 // Tiny CheckSum for MCommandMsg 00030 inline unsigned short MBuildCheckSum(MPacketHeader* pPacket) 00031 { 00032 int nStartOffset = sizeof(MPacketHeader); 00033 BYTE* pBulk = (BYTE*)pPacket; 00034 int nBulkSize = pPacket->nSize - sizeof(MPacketHeader); 00035 unsigned long nCheckSum = 0; 00036 for (int i=nStartOffset; i<nBulkSize; i++) { 00037 nCheckSum += pBulk[i]; 00038 } 00039 nCheckSum += pBulk[0]+pBulk[1]+pBulk[2]+pBulk[3]; 00040 unsigned short nShortCheckSum = HIWORD(nCheckSum) + LOWORD(nCheckSum); 00041 return nShortCheckSum; 00042 } 00043 00044 00045 #endif
MAIET entertainment