| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- /*
- ** 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. //
- // //
- ////////////////////////////////////////////////////////////////////////////////
- #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
- #include "GameNetwork/NetCommandMsg.h"
- #include "Common/GameState.h"
- #include "Common/PlayerList.h"
- #include "Common/Player.h"
- /**
- * Base constructor
- */
- NetCommandMsg::NetCommandMsg()
- {
- //Added By Sadullah Nader
- //Initializations inserted
- m_executionFrame = 0;
- m_id = 0;
- m_playerID = 0;
- //
- m_timestamp = 0;
- m_referenceCount = 1; // start this off as 1. This means that an "attach" is implied by creating a NetCommandMsg object.
- m_commandType = NETCOMMANDTYPE_UNKNOWN;
- }
- /**
- * Destructor
- */
- NetCommandMsg::~NetCommandMsg() {
- }
- /**
- * Adds one to the reference count.
- */
- void NetCommandMsg::attach() {
- ++m_referenceCount;
- }
- /**
- * Subtracts one from the reference count. If the reference count is 0, the this object is destroyed.
- */
- void NetCommandMsg::detach() {
- --m_referenceCount;
- if (m_referenceCount == 0) {
- deleteInstance();
- return;
- }
- DEBUG_ASSERTCRASH(m_referenceCount > 0, ("Invalid reference count for NetCommandMsg")); // Just to make sure...
- if (m_referenceCount < 0) {
- deleteInstance();
- }
- }
- /**
- * Returns the value by which this type of message should be sorted.
- */
- Int NetCommandMsg::getSortNumber() {
- return m_id;
- }
- //-------------------------------
- // NetGameCommandMsg
- //-------------------------------
- /**
- * Constructor with no argument, sets everything to default values.
- */
- NetGameCommandMsg::NetGameCommandMsg() : NetCommandMsg() {
- //Added By Sadullah Nader
- //Initializations inserted
- m_argSize = 0;
- m_numArgs = 0;
- //
- m_type = (GameMessage::Type)0;
- m_commandType = NETCOMMANDTYPE_GAMECOMMAND;
- m_argList = NULL;
- m_argTail = NULL;
- }
- /**
- * Constructor with a GameMessage argument. Sets member variables appropriately for this GameMessage.
- * Also copies all the arguments.
- */
- NetGameCommandMsg::NetGameCommandMsg(GameMessage *msg) : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_GAMECOMMAND;
- m_type = msg->getType();
- Int count = msg->getArgumentCount();
- for (Int i = 0; i < count; ++i) {
- addArgument(msg->getArgumentDataType(i), *(msg->getArgument(i)));
- }
- }
- /**
- * Destructor
- */
- NetGameCommandMsg::~NetGameCommandMsg() {
- GameMessageArgument *arg = m_argList;
- while (arg != NULL) {
- m_argList = m_argList->m_next;
- arg->deleteInstance();
- arg = m_argList;
- }
- }
- /**
- * Add an argument to this command.
- */
- void NetGameCommandMsg::addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg)
- {
- if (m_argTail == NULL) {
- m_argList = newInstance(GameMessageArgument);
- m_argTail = m_argList;
- m_argList->m_data = arg;
- m_argList->m_type = type;
- m_argList->m_next = NULL;
- return;
- }
- GameMessageArgument *newArg = newInstance(GameMessageArgument);
- newArg->m_data = arg;
- newArg->m_type = type;
- newArg->m_next = NULL;
- m_argTail->m_next = newArg;
- m_argTail = newArg;
- }
- // here's where we figure out which slot corresponds to which player
- static Int indexFromMask(UnsignedInt mask)
- {
- Player *player = NULL;
- Int i;
- for( i = 0; i < MAX_PLAYER_COUNT; i++ )
- {
- player = ThePlayerList->getNthPlayer( i );
- if( player && player->getPlayerMask() == mask )
- return i;
- } // end for i
- return -1;
- }
- /**
- * Construct a new GameMessage object from the data in this object.
- */
- GameMessage *NetGameCommandMsg::constructGameMessage()
- {
- GameMessage *retval = newInstance(GameMessage)(m_type);
- AsciiString name;
- name.format("player%d", getPlayerID());
- retval->friend_setPlayerIndex( ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(name))->getPlayerIndex());
- // retval->friend_setPlayerIndex(indexFromMask(ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(name))->getPlayerMask()));
- GameMessageArgument *arg = m_argList;
- while (arg != NULL) {
- // retval->appendGenericArgument(arg->m_data);
- if (arg->m_type == ARGUMENTDATATYPE_INTEGER) {
- retval->appendIntegerArgument(arg->m_data.integer);
- } else if (arg->m_type == ARGUMENTDATATYPE_REAL) {
- retval->appendRealArgument(arg->m_data.real);
- } else if (arg->m_type == ARGUMENTDATATYPE_BOOLEAN) {
- retval->appendBooleanArgument(arg->m_data.boolean);
- } else if (arg->m_type == ARGUMENTDATATYPE_OBJECTID) {
- retval->appendObjectIDArgument(arg->m_data.objectID);
- } else if (arg->m_type == ARGUMENTDATATYPE_DRAWABLEID) {
- retval->appendDrawableIDArgument(arg->m_data.drawableID);
- } else if (arg->m_type == ARGUMENTDATATYPE_TEAMID) {
- retval->appendTeamIDArgument(arg->m_data.teamID);
- } else if (arg->m_type == ARGUMENTDATATYPE_LOCATION) {
- retval->appendLocationArgument(arg->m_data.location);
- } else if (arg->m_type == ARGUMENTDATATYPE_PIXEL) {
- retval->appendPixelArgument(arg->m_data.pixel);
- } else if (arg->m_type == ARGUMENTDATATYPE_PIXELREGION) {
- retval->appendPixelRegionArgument(arg->m_data.pixelRegion);
- } else if (arg->m_type == ARGUMENTDATATYPE_TIMESTAMP) {
- retval->appendTimestampArgument(arg->m_data.timestamp);
- } else if (arg->m_type == ARGUMENTDATATYPE_WIDECHAR) {
- retval->appendWideCharArgument(arg->m_data.wChar);
- }
- arg = arg->m_next;
- }
- return retval;
- }
- /**
- * Sets the type of game message
- */
- void NetGameCommandMsg::setGameMessageType(GameMessage::Type type) {
- m_type = type;
- }
- AsciiString NetGameCommandMsg::getContentsAsAsciiString(void)
- {
- AsciiString ret;
- //AsciiString tmp;
- ret.format("Type:%s", GameMessage::getCommandTypeAsAsciiString((GameMessage::Type)m_type).str());
- return ret;
- }
- //-------------------------
- // NetAckBothCommandMsg
- //-------------------------
- /**
- * Constructor. Sets the member variables according to the given message.
- */
- NetAckBothCommandMsg::NetAckBothCommandMsg(NetCommandMsg *msg) : NetCommandMsg() {
- m_commandID = msg->getID();
- m_commandType = NETCOMMANDTYPE_ACKBOTH;
- m_originalPlayerID = msg->getPlayerID();
- }
- /**
- * Constructor. Sets the member variables to default values.
- */
- NetAckBothCommandMsg::NetAckBothCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_ACKBOTH;
- }
- /**
- * Destructor.
- */
- NetAckBothCommandMsg::~NetAckBothCommandMsg() {
- }
- /**
- * Returns the command ID of the command being ack'd.
- */
- UnsignedShort NetAckBothCommandMsg::getCommandID() {
- return m_commandID;
- }
- /**
- * Set the command ID of the command being ack'd.
- */
- void NetAckBothCommandMsg::setCommandID(UnsignedShort commandID) {
- m_commandID = commandID;
- }
- /**
- * Get the player id of the player who originally sent the command.
- */
- UnsignedByte NetAckBothCommandMsg::getOriginalPlayerID() {
- return m_originalPlayerID;
- }
- /**
- * Set the player id of the player who originally sent the command.
- */
- void NetAckBothCommandMsg::setOriginalPlayerID(UnsignedByte originalPlayerID) {
- m_originalPlayerID = originalPlayerID;
- }
- Int NetAckBothCommandMsg::getSortNumber() {
- return m_commandID;
- }
- //-------------------------
- // NetAckStage1CommandMsg
- //-------------------------
- /**
- * Constructor. Sets the member variables according to the given message.
- */
- NetAckStage1CommandMsg::NetAckStage1CommandMsg(NetCommandMsg *msg) : NetCommandMsg() {
- m_commandID = msg->getID();
- m_commandType = NETCOMMANDTYPE_ACKSTAGE1;
- m_originalPlayerID = msg->getPlayerID();
- }
- /**
- * Constructor. Sets the member variables to default values.
- */
- NetAckStage1CommandMsg::NetAckStage1CommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_ACKSTAGE1;
- }
- /**
- * Destructor.
- */
- NetAckStage1CommandMsg::~NetAckStage1CommandMsg() {
- }
- /**
- * Returns the command ID of the command being ack'd.
- */
- UnsignedShort NetAckStage1CommandMsg::getCommandID() {
- return m_commandID;
- }
- /**
- * Set the command ID of the command being ack'd.
- */
- void NetAckStage1CommandMsg::setCommandID(UnsignedShort commandID) {
- m_commandID = commandID;
- }
- /**
- * Get the player id of the player who originally sent the command.
- */
- UnsignedByte NetAckStage1CommandMsg::getOriginalPlayerID() {
- return m_originalPlayerID;
- }
- /**
- * Set the player id of the player who originally sent the command.
- */
- void NetAckStage1CommandMsg::setOriginalPlayerID(UnsignedByte originalPlayerID) {
- m_originalPlayerID = originalPlayerID;
- }
- Int NetAckStage1CommandMsg::getSortNumber() {
- return m_commandID;
- }
- //-------------------------
- // NetAckStage2CommandMsg
- //-------------------------
- /**
- * Constructor. Sets the member variables according to the given message.
- */
- NetAckStage2CommandMsg::NetAckStage2CommandMsg(NetCommandMsg *msg) : NetCommandMsg() {
- m_commandID = msg->getID();
- m_commandType = NETCOMMANDTYPE_ACKSTAGE2;
- m_originalPlayerID = msg->getPlayerID();
- }
- /**
- * Constructor. Sets the member variables to default values.
- */
- NetAckStage2CommandMsg::NetAckStage2CommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_ACKSTAGE2;
- }
- /**
- * Destructor.
- */
- NetAckStage2CommandMsg::~NetAckStage2CommandMsg() {
- }
- /**
- * Returns the command ID of the command being ack'd.
- */
- UnsignedShort NetAckStage2CommandMsg::getCommandID() {
- return m_commandID;
- }
- /**
- * Set the command ID of the command being ack'd.
- */
- void NetAckStage2CommandMsg::setCommandID(UnsignedShort commandID) {
- m_commandID = commandID;
- }
- /**
- * Get the player id of the player who originally sent the command.
- */
- UnsignedByte NetAckStage2CommandMsg::getOriginalPlayerID() {
- return m_originalPlayerID;
- }
- /**
- * Set the player id of the player who originally sent the command.
- */
- void NetAckStage2CommandMsg::setOriginalPlayerID(UnsignedByte originalPlayerID) {
- m_originalPlayerID = originalPlayerID;
- }
- Int NetAckStage2CommandMsg::getSortNumber() {
- return m_commandID;
- }
- //-------------------------
- // NetFrameCommandMsg
- //-------------------------
- /**
- * Constructor.
- */
- NetFrameCommandMsg::NetFrameCommandMsg() : NetCommandMsg() {
- m_commandCount = 0;
- m_commandType = NETCOMMANDTYPE_FRAMEINFO;
- }
- /**
- * Destructor
- */
- NetFrameCommandMsg::~NetFrameCommandMsg() {
- }
- /**
- * Set the command count of this frame.
- */
- void NetFrameCommandMsg::setCommandCount(UnsignedShort commandCount) {
- m_commandCount = commandCount;
- }
- /**
- * Return the command count of this frame.
- */
- UnsignedShort NetFrameCommandMsg::getCommandCount() {
- return m_commandCount;
- }
- //-------------------------
- // NetPlayerLeaveCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetPlayerLeaveCommandMsg::NetPlayerLeaveCommandMsg() : NetCommandMsg() {
- m_leavingPlayerID = 0;
- m_commandType = NETCOMMANDTYPE_PLAYERLEAVE;
- }
- /**
- * Destructor
- */
- NetPlayerLeaveCommandMsg::~NetPlayerLeaveCommandMsg() {
- }
- /**
- * Get the id of the player leaving the game.
- */
- UnsignedByte NetPlayerLeaveCommandMsg::getLeavingPlayerID() {
- return m_leavingPlayerID;
- }
- /**
- * Set the id of the player leaving the game.
- */
- void NetPlayerLeaveCommandMsg::setLeavingPlayerID(UnsignedByte id) {
- m_leavingPlayerID = id;
- }
- //-------------------------
- // NetRunAheadMetricsCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetRunAheadMetricsCommandMsg::NetRunAheadMetricsCommandMsg() : NetCommandMsg() {
- m_averageLatency = 0.0;
- m_averageFps = 0;
- m_commandType = NETCOMMANDTYPE_RUNAHEADMETRICS;
- }
- /**
- * Destructor
- */
- NetRunAheadMetricsCommandMsg::~NetRunAheadMetricsCommandMsg() {
- }
- /**
- * set the average latency
- */
- void NetRunAheadMetricsCommandMsg::setAverageLatency(Real avgLat) {
- m_averageLatency = avgLat;
- }
- /**
- * get the average latency
- */
- Real NetRunAheadMetricsCommandMsg::getAverageLatency() {
- return m_averageLatency;
- }
- /**
- * set the average fps
- */
- void NetRunAheadMetricsCommandMsg::setAverageFps(Int fps) {
- m_averageFps = fps;
- }
- /**
- * get the average fps
- */
- Int NetRunAheadMetricsCommandMsg::getAverageFps() {
- return m_averageFps;
- }
- //-------------------------
- // NetRunAheadCommandMsg
- //-------------------------
- NetRunAheadCommandMsg::NetRunAheadCommandMsg() : NetCommandMsg() {
- m_runAhead = min(max(20, MIN_RUNAHEAD), MAX_FRAMES_AHEAD/2);
- m_frameRate = 30;
- m_commandType = NETCOMMANDTYPE_RUNAHEAD;
- }
- NetRunAheadCommandMsg::~NetRunAheadCommandMsg() {
- }
- UnsignedShort NetRunAheadCommandMsg::getRunAhead() {
- return m_runAhead;
- }
- void NetRunAheadCommandMsg::setRunAhead(UnsignedShort runAhead) {
- m_runAhead = runAhead;
- }
- UnsignedByte NetRunAheadCommandMsg::getFrameRate() {
- return m_frameRate;
- }
- void NetRunAheadCommandMsg::setFrameRate(UnsignedByte frameRate) {
- m_frameRate = frameRate;
- }
- //-------------------------
- // NetDestroyPlayerCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetDestroyPlayerCommandMsg::NetDestroyPlayerCommandMsg() : NetCommandMsg()
- {
- m_playerIndex = 0;
- m_commandType = NETCOMMANDTYPE_DESTROYPLAYER;
- }
- /**
- * Destructor
- */
- NetDestroyPlayerCommandMsg::~NetDestroyPlayerCommandMsg()
- {
- }
- /**
- * set the CRC
- */
- void NetDestroyPlayerCommandMsg::setPlayerIndex( UnsignedInt playerIndex )
- {
- m_playerIndex = playerIndex;
- }
- /**
- * get the average CRC
- */
- UnsignedInt NetDestroyPlayerCommandMsg::getPlayerIndex( void )
- {
- return m_playerIndex;
- }
- //-------------------------
- // NetKeepAliveCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetKeepAliveCommandMsg::NetKeepAliveCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_KEEPALIVE;
- }
- NetKeepAliveCommandMsg::~NetKeepAliveCommandMsg() {
- }
- //-------------------------
- // NetDisconnectKeepAliveCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetDisconnectKeepAliveCommandMsg::NetDisconnectKeepAliveCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTKEEPALIVE;
- }
- NetDisconnectKeepAliveCommandMsg::~NetDisconnectKeepAliveCommandMsg() {
- }
- //-------------------------
- // NetDisconnectPlayerCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetDisconnectPlayerCommandMsg::NetDisconnectPlayerCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTPLAYER;
- m_disconnectSlot = 0;
- }
- /**
- * Destructor
- */
- NetDisconnectPlayerCommandMsg::~NetDisconnectPlayerCommandMsg() {
- }
- /**
- * Returns the disconnecting slot number
- */
- UnsignedByte NetDisconnectPlayerCommandMsg::getDisconnectSlot() {
- return m_disconnectSlot;
- }
- /**
- * Sets the disconnecting slot number
- */
- void NetDisconnectPlayerCommandMsg::setDisconnectSlot(UnsignedByte slot) {
- m_disconnectSlot = slot;
- }
- /**
- * Sets the disconnect frame
- */
- void NetDisconnectPlayerCommandMsg::setDisconnectFrame(UnsignedInt frame) {
- m_disconnectFrame = frame;
- }
- /**
- * returns the disconnect frame
- */
- UnsignedInt NetDisconnectPlayerCommandMsg::getDisconnectFrame() {
- return m_disconnectFrame;
- }
- //-------------------------
- // NetPacketRouterQueryCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetPacketRouterQueryCommandMsg::NetPacketRouterQueryCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_PACKETROUTERQUERY;
- }
- /**
- * Destructor
- */
- NetPacketRouterQueryCommandMsg::~NetPacketRouterQueryCommandMsg() {
- }
- //-------------------------
- // NetPacketRouterAckCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetPacketRouterAckCommandMsg::NetPacketRouterAckCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_PACKETROUTERACK;
- }
- /**
- * Destructor
- */
- NetPacketRouterAckCommandMsg::~NetPacketRouterAckCommandMsg() {
- }
- //-------------------------
- // NetDisconnectChatCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetDisconnectChatCommandMsg::NetDisconnectChatCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTCHAT;
- }
- /**
- * Destructor
- */
- NetDisconnectChatCommandMsg::~NetDisconnectChatCommandMsg() {
- }
- /**
- * Set the chat text for this message.
- */
- void NetDisconnectChatCommandMsg::setText(UnicodeString text) {
- m_text = text;
- }
- /**
- * Get the chat text for this message.
- */
- UnicodeString NetDisconnectChatCommandMsg::getText() {
- return m_text;
- }
- //-------------------------
- // NetChatCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetChatCommandMsg::NetChatCommandMsg() : NetCommandMsg()
- {
- m_commandType = NETCOMMANDTYPE_CHAT;
- //added by Sadullah Nader
- //Initializations inserted
- m_playerMask = 0;
- //
- }
- /**
- * Destructor
- */
- NetChatCommandMsg::~NetChatCommandMsg()
- {
- }
- /**
- * Set the chat text for this message.
- */
- void NetChatCommandMsg::setText(UnicodeString text)
- {
- m_text = text;
- }
- /**
- * Get the chat text for this message.
- */
- UnicodeString NetChatCommandMsg::getText()
- {
- return m_text;
- }
- /**
- * Get the bitmask of chat recipients from this message.
- */
- Int NetChatCommandMsg::getPlayerMask()
- {
- return m_playerMask;
- }
- /**
- * Set a bitmask of chat recipients in this message.
- */
- void NetChatCommandMsg::setPlayerMask( Int playerMask )
- {
- m_playerMask = playerMask;
- }
- //-------------------------
- // NetDisconnectVoteCommandMsg
- //-------------------------
- /**
- * Constructor
- */
- NetDisconnectVoteCommandMsg::NetDisconnectVoteCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTVOTE;
- m_slot = 0;
- }
- /**
- * Destructor
- */
- NetDisconnectVoteCommandMsg::~NetDisconnectVoteCommandMsg() {
- }
- /**
- * Set the slot that is being voted for.
- */
- void NetDisconnectVoteCommandMsg::setSlot(UnsignedByte slot) {
- m_slot = slot;
- }
- /**
- * Get the slot that is being voted for.
- */
- UnsignedByte NetDisconnectVoteCommandMsg::getSlot() {
- return m_slot;
- }
- /**
- * Get the vote frame.
- */
- UnsignedInt NetDisconnectVoteCommandMsg::getVoteFrame() {
- return m_voteFrame;
- }
- /**
- * Set the vote frame.
- */
- void NetDisconnectVoteCommandMsg::setVoteFrame(UnsignedInt voteFrame) {
- m_voteFrame = voteFrame;
- }
- //-------------------------
- // NetProgressCommandMsg
- //-------------------------
- NetProgressCommandMsg::NetProgressCommandMsg( void ) : NetCommandMsg()
- {
- m_commandType = NETCOMMANDTYPE_PROGRESS;
- m_percent = 0;
- }
- NetProgressCommandMsg::~NetProgressCommandMsg( void ) {}
-
- UnsignedByte NetProgressCommandMsg::getPercentage()
- {
- return m_percent;
- }
- void NetProgressCommandMsg::setPercentage( UnsignedByte percent )
- {
- m_percent = percent;
- }
- //-------------------------
- // NetWrapperCommandMsg
- //-------------------------
- NetWrapperCommandMsg::NetWrapperCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_WRAPPER;
- m_numChunks = 0;
- m_data = NULL;
- m_totalDataLength = 0;
- m_chunkNumber = 0;
- m_dataLength = 0;
- m_dataOffset = 0;
- m_wrappedCommandID = 0;
- }
- NetWrapperCommandMsg::~NetWrapperCommandMsg() {
- if (m_data != NULL) {
- delete m_data;
- m_data = NULL;
- }
- }
- UnsignedByte * NetWrapperCommandMsg::getData() {
- return m_data;
- }
- void NetWrapperCommandMsg::setData(UnsignedByte *data, UnsignedInt dataLength)
- {
- if (m_data != NULL) {
- delete m_data;
- m_data = NULL;
- }
- m_data = NEW UnsignedByte[dataLength]; // pool[]ify
- memcpy(m_data, data, dataLength);
- m_dataLength = dataLength;
- }
- UnsignedInt NetWrapperCommandMsg::getDataLength() {
- return m_dataLength;
- }
- UnsignedInt NetWrapperCommandMsg::getDataOffset() {
- return m_dataOffset;
- }
- void NetWrapperCommandMsg::setDataOffset(UnsignedInt offset) {
- m_dataOffset = offset;
- }
- UnsignedInt NetWrapperCommandMsg::getChunkNumber() {
- return m_chunkNumber;
- }
- void NetWrapperCommandMsg::setChunkNumber(UnsignedInt chunkNumber) {
- m_chunkNumber = chunkNumber;
- }
- UnsignedInt NetWrapperCommandMsg::getNumChunks() {
- return m_numChunks;
- }
- void NetWrapperCommandMsg::setNumChunks(UnsignedInt numChunks) {
- m_numChunks = numChunks;
- }
- UnsignedInt NetWrapperCommandMsg::getTotalDataLength() {
- return m_totalDataLength;
- }
- void NetWrapperCommandMsg::setTotalDataLength(UnsignedInt totalDataLength) {
- m_totalDataLength = totalDataLength;
- }
- UnsignedShort NetWrapperCommandMsg::getWrappedCommandID() {
- return m_wrappedCommandID;
- }
- void NetWrapperCommandMsg::setWrappedCommandID(UnsignedShort wrappedCommandID) {
- m_wrappedCommandID = wrappedCommandID;
- }
- //-------------------------
- // NetFileCommandMsg
- //-------------------------
- NetFileCommandMsg::NetFileCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_FILE;
- m_data = NULL;
- m_portableFilename.clear();
- m_dataLength = 0;
- }
- NetFileCommandMsg::~NetFileCommandMsg() {
- if (m_data != NULL) {
- delete[] m_data;
- m_data = NULL;
- }
- }
- AsciiString NetFileCommandMsg::getRealFilename()
- {
- return TheGameState->portableMapPathToRealMapPath(m_portableFilename);
- }
- void NetFileCommandMsg::setRealFilename(AsciiString filename)
- {
- m_portableFilename = TheGameState->realMapPathToPortableMapPath(filename);
- }
- UnsignedInt NetFileCommandMsg::getFileLength() {
- return m_dataLength;
- }
- UnsignedByte * NetFileCommandMsg::getFileData() {
- return m_data;
- }
- void NetFileCommandMsg::setFileData(UnsignedByte *data, UnsignedInt dataLength)
- {
- m_dataLength = dataLength;
- m_data = NEW UnsignedByte[dataLength]; // pool[]ify
- memcpy(m_data, data, dataLength);
- }
- //-------------------------
- // NetFileAnnounceCommandMsg
- //-------------------------
- NetFileAnnounceCommandMsg::NetFileAnnounceCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_FILEANNOUNCE;
- m_portableFilename.clear();
- m_fileID = 0;
- m_playerMask = 0;
- }
- NetFileAnnounceCommandMsg::~NetFileAnnounceCommandMsg() {
- }
- AsciiString NetFileAnnounceCommandMsg::getRealFilename()
- {
- return TheGameState->portableMapPathToRealMapPath(m_portableFilename);
- }
- void NetFileAnnounceCommandMsg::setRealFilename(AsciiString filename)
- {
- m_portableFilename = TheGameState->realMapPathToPortableMapPath(filename);
- }
- UnsignedShort NetFileAnnounceCommandMsg::getFileID() {
- return m_fileID;
- }
- void NetFileAnnounceCommandMsg::setFileID(UnsignedShort fileID) {
- m_fileID = fileID;
- }
- UnsignedByte NetFileAnnounceCommandMsg::getPlayerMask(void) {
- return m_playerMask;
- }
- void NetFileAnnounceCommandMsg::setPlayerMask(UnsignedByte playerMask) {
- m_playerMask = playerMask;
- }
- //-------------------------
- // NetFileProgressCommandMsg
- //-------------------------
- NetFileProgressCommandMsg::NetFileProgressCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_FILEPROGRESS;
- m_fileID = 0;
- m_progress = 0;
- }
- NetFileProgressCommandMsg::~NetFileProgressCommandMsg() {
- }
- UnsignedShort NetFileProgressCommandMsg::getFileID() {
- return m_fileID;
- }
- void NetFileProgressCommandMsg::setFileID(UnsignedShort val) {
- m_fileID = val;
- }
- Int NetFileProgressCommandMsg::getProgress() {
- return m_progress;
- }
- void NetFileProgressCommandMsg::setProgress(Int val) {
- m_progress = val;
- }
- //-------------------------
- // NetDisconnectFrameCommandMsg
- //-------------------------
- NetDisconnectFrameCommandMsg::NetDisconnectFrameCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTFRAME;
- m_disconnectFrame = 0;
- }
- NetDisconnectFrameCommandMsg::~NetDisconnectFrameCommandMsg() {
- }
- UnsignedInt NetDisconnectFrameCommandMsg::getDisconnectFrame() {
- return m_disconnectFrame;
- }
- void NetDisconnectFrameCommandMsg::setDisconnectFrame(UnsignedInt disconnectFrame) {
- m_disconnectFrame = disconnectFrame;
- }
- //-------------------------
- // NetDisconnectScreenOffCommandMsg
- //-------------------------
- NetDisconnectScreenOffCommandMsg::NetDisconnectScreenOffCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_DISCONNECTSCREENOFF;
- m_newFrame = 0;
- }
- NetDisconnectScreenOffCommandMsg::~NetDisconnectScreenOffCommandMsg() {
- }
- UnsignedInt NetDisconnectScreenOffCommandMsg::getNewFrame() {
- return m_newFrame;
- }
- void NetDisconnectScreenOffCommandMsg::setNewFrame(UnsignedInt newFrame) {
- m_newFrame = newFrame;
- }
- //-------------------------
- // NetFrameResendRequestCommandMsg
- //-------------------------
- NetFrameResendRequestCommandMsg::NetFrameResendRequestCommandMsg() : NetCommandMsg() {
- m_commandType = NETCOMMANDTYPE_FRAMERESENDREQUEST;
- m_frameToResend = 0;
- }
- NetFrameResendRequestCommandMsg::~NetFrameResendRequestCommandMsg() {
- }
- UnsignedInt NetFrameResendRequestCommandMsg::getFrameToResend() {
- return m_frameToResend;
- }
- void NetFrameResendRequestCommandMsg::setFrameToResend(UnsignedInt frame) {
- m_frameToResend = frame;
- }
|