| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- /*
- ** Command & Conquer Generals Zero Hour(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- ////////////////////////////////////////////////////////////////////////////////
- // //
- // (c) 2001-2003 Electronic Arts Inc. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- //------------------------------------------------------------------------------------
- // The CommandMsg class is a linked-list wrapper around GameMessage objects that
- // are queued up to execute at a later time
- #pragma once
- #ifndef __NETCOMMANDMSG_H
- #define __NETCOMMANDMSG_H
- #include "Lib/BaseType.h"
- #include "GameNetwork/NetworkDefs.h"
- #include "Common/UnicodeString.h"
- //-----------------------------------------------------------------------------
- class NetCommandMsg : public MemoryPoolObject
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetCommandMsg, "NetCommandMsg")
- public:
- NetCommandMsg();
- //virtual ~NetCommandMsg();
- inline UnsignedInt GetTimestamp() { return m_timestamp; }
- inline void SetTimestamp(UnsignedInt timestamp) { m_timestamp = timestamp; }
- inline void setExecutionFrame(UnsignedInt frame) { m_executionFrame = frame; }
- inline void setPlayerID(UnsignedInt playerID) { m_playerID = playerID; }
- inline void setID(UnsignedShort id) { m_id = id; }
- inline UnsignedInt getExecutionFrame() { return m_executionFrame; }
- inline UnsignedInt getPlayerID() { return m_playerID; }
- inline UnsignedShort getID() { return m_id; }
- inline void setNetCommandType(NetCommandType type) { m_commandType = type; }
- inline NetCommandType getNetCommandType() { return m_commandType; }
- virtual Int getSortNumber();
- void attach();
- void detach();
- // For debugging purposes
- virtual AsciiString getContentsAsAsciiString(void) { return AsciiString::TheEmptyString; }
- protected:
- UnsignedInt m_timestamp;
- UnsignedInt m_executionFrame;
- UnsignedInt m_playerID;
- UnsignedShort m_id;
- NetCommandType m_commandType;
- Int m_referenceCount;
- };
- //-----------------------------------------------------------------------------
- /**
- * The NetGameCommandMsg is the NetCommandMsg representation of a GameMessage
- */
- class NetGameCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetGameCommandMsg, "NetGameCommandMsg")
- public:
- NetGameCommandMsg();
- NetGameCommandMsg(GameMessage *msg);
- //virtual ~NetGameCommandMsg();
- GameMessage *constructGameMessage();
- void addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg);
- void setGameMessageType(GameMessage::Type type);
- // For debugging purposes
- virtual AsciiString getContentsAsAsciiString(void);
- protected:
- Int m_numArgs;
- Int m_argSize;
- GameMessage::Type m_type;
- GameMessageArgument *m_argList, *m_argTail;
- };
- //-----------------------------------------------------------------------------
- /**
- * The NetAckBothCommandMsg is the NetCommandMsg representation of the combination of a
- * stage 1 ack and a stage 2 ack.
- */
- class NetAckBothCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetAckBothCommandMsg, "NetAckBothCommandMsg")
- public:
- NetAckBothCommandMsg(NetCommandMsg *msg);
- NetAckBothCommandMsg();
- //virtual ~NetAckBothCommandMsg();
- UnsignedShort getCommandID();
- void setCommandID(UnsignedShort commandID);
- UnsignedByte getOriginalPlayerID();
- void setOriginalPlayerID(UnsignedByte originalPlayerID);
- virtual Int getSortNumber();
- protected:
- UnsignedShort m_commandID;
- UnsignedByte m_originalPlayerID;
- };
- //-----------------------------------------------------------------------------
- /**
- * The NetAckStage1CommandMsg is the NetCommandMsg representation of an ack message for the initial
- * recipient.
- */
- class NetAckStage1CommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetAckStage1CommandMsg, "NetAckStage1CommandMsg")
- public:
- NetAckStage1CommandMsg(NetCommandMsg *msg);
- NetAckStage1CommandMsg();
- //virtual ~NetAckStage1CommandMsg();
- UnsignedShort getCommandID();
- void setCommandID(UnsignedShort commandID);
- UnsignedByte getOriginalPlayerID();
- void setOriginalPlayerID(UnsignedByte originalPlayerID);
- virtual Int getSortNumber();
- protected:
- UnsignedShort m_commandID;
- UnsignedByte m_originalPlayerID;
- };
- //-----------------------------------------------------------------------------
- /**
- * The NetAckStage2CommandMsg is the NetCommandMsg representation of an ack message for all eventual
- * recipients. (when this is returned, all the players in the relay mask have received the packet)
- */
- class NetAckStage2CommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetAckStage2CommandMsg, "NetAckStage2CommandMsg")
- public:
- NetAckStage2CommandMsg(NetCommandMsg *msg);
- NetAckStage2CommandMsg();
- //virtual ~NetAckStage2CommandMsg();
- UnsignedShort getCommandID();
- void setCommandID(UnsignedShort commandID);
- UnsignedByte getOriginalPlayerID();
- void setOriginalPlayerID(UnsignedByte originalPlayerID);
- virtual Int getSortNumber();
- protected:
- UnsignedShort m_commandID;
- UnsignedByte m_originalPlayerID;
- };
- //-----------------------------------------------------------------------------
- class NetFrameCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetFrameCommandMsg, "NetFrameCommandMsg")
- public:
- NetFrameCommandMsg();
- //virtual ~NetFrameCommandMsg();
- void setCommandCount(UnsignedShort commandCount);
- UnsignedShort getCommandCount();
- protected:
- UnsignedShort m_commandCount;
- };
- //-----------------------------------------------------------------------------
- class NetPlayerLeaveCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetPlayerLeaveCommandMsg, "NetPlayerLeaveCommandMsg")
- public:
- NetPlayerLeaveCommandMsg();
- //virtual ~NetPlayerLeaveCommandMsg();
- UnsignedByte getLeavingPlayerID();
- void setLeavingPlayerID(UnsignedByte id);
- protected:
- UnsignedByte m_leavingPlayerID;
- };
- //-----------------------------------------------------------------------------
- class NetRunAheadMetricsCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetRunAheadMetricsCommandMsg, "NetRunAheadMetricsCommandMsg")
- public:
- NetRunAheadMetricsCommandMsg();
- //virtual ~NetRunAheadMetricsCommandMsg();
- Real getAverageLatency();
- void setAverageLatency(Real avgLat);
- Int getAverageFps();
- void setAverageFps(Int fps);
- protected:
- Real m_averageLatency;
- Int m_averageFps;
- };
- //-----------------------------------------------------------------------------
- class NetRunAheadCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetRunAheadCommandMsg, "NetRunAheadCommandMsg")
- public:
- NetRunAheadCommandMsg();
- //virtual ~NetRunAheadCommandMsg();
- UnsignedShort getRunAhead();
- void setRunAhead(UnsignedShort runAhead);
- UnsignedByte getFrameRate();
- void setFrameRate(UnsignedByte frameRate);
- protected:
- UnsignedShort m_runAhead;
- UnsignedByte m_frameRate;
- };
- //-----------------------------------------------------------------------------
- class NetDestroyPlayerCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDestroyPlayerCommandMsg, "NetDestroyPlayerCommandMsg")
- public:
- NetDestroyPlayerCommandMsg();
- //virtual ~NetDestroyPlayerCommandMsg();
- UnsignedInt getPlayerIndex();
- void setPlayerIndex(UnsignedInt playerIndex);
- protected:
- UnsignedInt m_playerIndex;
- };
- //-----------------------------------------------------------------------------
- class NetKeepAliveCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetKeepAliveCommandMsg, "NetKeepAliveCommandMsg")
- public:
- NetKeepAliveCommandMsg();
- //virtual ~NetKeepAliveCommandMsg();
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectKeepAliveCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectKeepAliveCommandMsg, "NetDisconnectKeepAliveCommandMsg")
- public:
- NetDisconnectKeepAliveCommandMsg();
- //virtual ~NetDisconnectKeepAliveCommandMsg();
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectPlayerCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectPlayerCommandMsg, "NetDisconnectPlayerCommandMsg")
- public:
- NetDisconnectPlayerCommandMsg();
- //virtual ~NetDisconnectPlayerCommandMsg();
- UnsignedByte getDisconnectSlot();
- void setDisconnectSlot(UnsignedByte slot);
- UnsignedInt getDisconnectFrame();
- void setDisconnectFrame(UnsignedInt frame);
- protected:
- UnsignedByte m_disconnectSlot;
- UnsignedInt m_disconnectFrame;
- };
- //-----------------------------------------------------------------------------
- class NetPacketRouterQueryCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetPacketRouterQueryCommandMsg, "NetPacketRouterQueryCommandMsg")
- public:
- NetPacketRouterQueryCommandMsg();
- //virtual ~NetPacketRouterQueryCommandMsg();
- };
- //-----------------------------------------------------------------------------
- class NetPacketRouterAckCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetPacketRouterAckCommandMsg, "NetPacketRouterAckCommandMsg")
- public:
- NetPacketRouterAckCommandMsg();
- //virtual ~NetPacketRouterAckCommandMsg();
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectChatCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectChatCommandMsg, "NetDisconnectChatCommandMsg")
- public:
- NetDisconnectChatCommandMsg();
- //virtual ~NetDisconnectChatCommandMsg();
- UnicodeString getText();
- void setText(UnicodeString text);
- protected:
- UnicodeString m_text;
- };
- //-----------------------------------------------------------------------------
- class NetChatCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetChatCommandMsg, "NetChatCommandMsg")
- public:
- NetChatCommandMsg();
- //virtual ~NetChatCommandMsg();
- UnicodeString getText();
- void setText(UnicodeString text);
- Int getPlayerMask( void );
- void setPlayerMask( Int playerMask );
- protected:
- UnicodeString m_text;
- Int m_playerMask;
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectVoteCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectVoteCommandMsg, "NetDisconnectVoteCommandMsg")
- public:
- NetDisconnectVoteCommandMsg();
- //virtual ~NetDisconnectVoteCommandMsg();
- UnsignedByte getSlot();
- void setSlot(UnsignedByte slot);
- UnsignedInt getVoteFrame();
- void setVoteFrame(UnsignedInt voteFrame);
- protected:
- UnsignedByte m_slot;
- UnsignedInt m_voteFrame;
- };
- //-----------------------------------------------------------------------------
- class NetProgressCommandMsg: public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetProgressCommandMsg, "NetProgressCommandMsg")
- public:
- NetProgressCommandMsg( void );
- //virtual ~NetProgressCommandMsg( void );
-
- UnsignedByte getPercentage();
- void setPercentage( UnsignedByte percent );
- protected:
- UnsignedByte m_percent;
- };
- //-----------------------------------------------------------------------------
- class NetWrapperCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetWrapperCommandMsg, "NetWrapperCommandMsg")
- public:
- NetWrapperCommandMsg( void );
- //virtual ~NetWrapperCommandMsg();
- UnsignedByte * getData();
- void setData(UnsignedByte *data, UnsignedInt dataLength);
-
- UnsignedInt getChunkNumber();
- void setChunkNumber(UnsignedInt chunkNumber);
- UnsignedInt getNumChunks();
- void setNumChunks(UnsignedInt numChunks);
- UnsignedInt getDataLength();
- UnsignedInt getTotalDataLength();
- void setTotalDataLength(UnsignedInt totalDataLength);
- UnsignedInt getDataOffset();
- void setDataOffset(UnsignedInt offset);
- UnsignedShort getWrappedCommandID();
- void setWrappedCommandID(UnsignedShort wrappedCommandID);
- private:
- UnsignedByte *m_data;
- // using UnsignedInt's so we can send around files of effectively unlimited size easily
- UnsignedInt m_dataLength;
- UnsignedInt m_dataOffset;
- UnsignedInt m_totalDataLength;
- UnsignedInt m_chunkNumber;
- UnsignedInt m_numChunks;
- UnsignedShort m_wrappedCommandID;
- };
- //-----------------------------------------------------------------------------
- class NetFileCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetFileCommandMsg, "NetFileCommandMsg")
- public:
- NetFileCommandMsg();
- //virtual ~NetFileCommandMsg();
- AsciiString getRealFilename();
- void setRealFilename(AsciiString filename);
- AsciiString getPortableFilename() { return m_portableFilename; }
- void setPortableFilename(AsciiString filename) { m_portableFilename = filename; }
- UnsignedInt getFileLength();
- UnsignedByte * getFileData();
- void setFileData(UnsignedByte *data, UnsignedInt dataLength);
- protected:
- AsciiString m_portableFilename;
- UnsignedByte *m_data;
- UnsignedInt m_dataLength;
- };
- //-----------------------------------------------------------------------------
- class NetFileAnnounceCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetFileAnnounceCommandMsg, "NetFileAnnounceCommandMsg")
- public:
- NetFileAnnounceCommandMsg();
- //virtual ~NetFileAnnounceCommandMsg();
- AsciiString getRealFilename();
- void setRealFilename(AsciiString filename);
- AsciiString getPortableFilename() { return m_portableFilename; }
- void setPortableFilename(AsciiString filename) { m_portableFilename = filename; }
- UnsignedShort getFileID();
- void setFileID(UnsignedShort fileID);
- UnsignedByte getPlayerMask(void);
- void setPlayerMask(UnsignedByte playerMask);
- protected:
- AsciiString m_portableFilename;
- UnsignedShort m_fileID;
- UnsignedByte m_playerMask;
- };
- //-----------------------------------------------------------------------------
- class NetFileProgressCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetFileProgressCommandMsg, "NetFileProgressCommandMsg")
- public:
- NetFileProgressCommandMsg();
- //virtual ~NetFileProgressCommandMsg();
- UnsignedShort getFileID();
- void setFileID(UnsignedShort val);
- Int getProgress();
- void setProgress(Int val);
- protected:
- UnsignedShort m_fileID;
- Int m_progress;
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectFrameCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectFrameCommandMsg, "NetDisconnectFrameCommandMsg")
- public:
- NetDisconnectFrameCommandMsg();
- UnsignedInt getDisconnectFrame();
- void setDisconnectFrame(UnsignedInt disconnectFrame);
- protected:
- UnsignedInt m_disconnectFrame;
- };
- //-----------------------------------------------------------------------------
- class NetDisconnectScreenOffCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetDisconnectScreenOffCommandMsg, "NetDisconnectScreenOffCommandMsg")
- public:
- NetDisconnectScreenOffCommandMsg();
- UnsignedInt getNewFrame();
- void setNewFrame(UnsignedInt newFrame);
- protected:
- UnsignedInt m_newFrame;
- };
- //-----------------------------------------------------------------------------
- class NetFrameResendRequestCommandMsg : public NetCommandMsg
- {
- MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetFrameResendRequestCommandMsg, "NetFrameResendRequestCommandMsg")
- public:
- NetFrameResendRequestCommandMsg();
-
- UnsignedInt getFrameToResend();
- void setFrameToResend(UnsignedInt frame);
-
- protected:
- UnsignedInt m_frameToResend;
- };
- #endif
|