#pragma once //===========================================================================// // Copyright (C) Microsoft Corporation. All rights reserved. // //===========================================================================// ////////////////////////////////////////////////////////////////////// // // NetworkMessages.hpp: interface for all network messages in Linkup Library // #include "directx.hpp" #include "networking.hpp" #include "Flinkedlist.hpp" #include "Net.hpp" #pragma pack(1) class FIMessageHeader { protected: unsigned short flags; #ifdef _ARMOR public: unsigned short packetNumber; #endif enum { TypeBits = 0, MulticastBit = TypeBits+11, GuaranteedBit }; enum { TypeMask = 0x3FF, // 1st 10 bits MulticastFlag = 1 << MulticastBit, GuaranteedFlag = 1 << GuaranteedBit }; public: FIMessageHeader() { flags = 0; } void Init() { flags = 0; } // Accessors inline bool IsMulticast() { if (flags & MulticastFlag) return true; else return false; } inline bool IsGuaranteed() { if (flags & GuaranteedFlag) return true; else return false; } // This message construct limits the application to // 1024 unique types of messages. inline int GetType() { return flags & TypeMask; } // Information setters inline void SetMulticast() { flags |= MulticastFlag; } inline void SetUnicast() { flags &= ~MulticastFlag; } inline void SetGuaranteed() { flags |= GuaranteedFlag; } inline void SetNonGuaranteed() { flags &= ~GuaranteedFlag; } inline void SetType(unsigned int new_type) { gosASSERT(new_type < 0x3FF); flags &= ~TypeMask; // clear the type flags |= (new_type); } }; class MessageTagger { public: unsigned char sendCounts[MAXPLAYERS]; inline void Clear() { int i; for (i=0; i