gameConnectionEvents.h
Engine/source/T3D/gameBase/gameConnectionEvents.h
Classes:
class
class
class
class
class
Event for sending a datablock over the net from the server to the client.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _GAMECONNECTIONEVENTS_H_ 25#define _GAMECONNECTIONEVENTS_H_ 26 27#ifndef _SIMBASE_H_ 28#include "console/simBase.h" 29#endif 30 31#ifndef _GAMECONNECTION_H_ 32#include "T3D/gameBase/gameConnection.h" 33#endif 34 35#ifndef _SFXPROFILE_H_ 36#include "sfx/sfxProfile.h" 37#endif 38 39#ifndef _BITSTREAM_H_ 40#include "core/stream/bitStream.h" 41#endif 42 43 44class QuitEvent : public SimEvent 45{ 46 void process(SimObject *object) 47 { 48 Platform::postQuitMessage(0); 49 } 50}; 51 52/// Event for sending a datablock over the net from the server to the client. 53/// 54/// Datablock events are GuaranteedOrdered client events. 55/// 56class SimDataBlockEvent : public NetEvent 57{ 58 public: 59 60 typedef NetEvent Parent; 61 62 protected: 63 64 /// Id of the datablock object to be sent. This must be a datablock ID 65 /// (as opposed to a normal object ID). 66 SimObjectId id; 67 68 /// 69 U32 mIndex; 70 71 /// Total number of datablocks that are part of this datablock transmission. 72 /// Each datablock is transmitted in an independent datablock event. 73 U32 mTotal; 74 75 /// The mission sequence number to which this datablock transmission 76 /// belongs. 77 /// 78 /// @see GameConnection::getDataBlockSequence 79 U32 mMissionSequence; 80 81 /// Datablock object constructed on the client side. 82 SimDataBlock *mObj; 83 84 /// 85 bool mProcess; 86 87 public: 88 89 SimDataBlockEvent(SimDataBlock* obj = NULL, U32 index = 0, U32 total = 0, U32 missionSequence = 0); 90 ~SimDataBlockEvent(); 91 92 void pack(NetConnection *, BitStream *bstream); 93 void write(NetConnection *, BitStream *bstream); 94 void unpack(NetConnection *cptr, BitStream *bstream); 95 void process(NetConnection*); 96 void notifyDelivered(NetConnection *, bool); 97 98 #ifdef TORQUE_DEBUG_NET 99 const char *getDebugName(); 100 #endif 101 102 DECLARE_CONOBJECT( SimDataBlockEvent ); 103 DECLARE_CATEGORY( "Game Networking" ); 104}; 105 106class Sim2DAudioEvent: public NetEvent 107{ 108 private: 109 SFXProfile *mProfile; 110 111 public: 112 typedef NetEvent Parent; 113 Sim2DAudioEvent(SFXProfile *profile=<a href="/coding/file/types_8lint_8h/#types_8lint_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>); 114 void pack(NetConnection *, BitStream *bstream); 115 void write(NetConnection *, BitStream *bstream); 116 void unpack(NetConnection *, BitStream *bstream); 117 void process(NetConnection *); 118 DECLARE_CONOBJECT(Sim2DAudioEvent); 119}; 120 121class Sim3DAudioEvent: public NetEvent 122{ 123 private: 124 SFXProfile *mProfile; 125 MatrixF mTransform; 126 127 public: 128 typedef NetEvent Parent; 129 Sim3DAudioEvent(SFXProfile *profile=<a href="/coding/file/types_8lint_8h/#types_8lint_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>,const MatrixF* mat=<a href="/coding/file/types_8lint_8h/#types_8lint_8h_1a070d2ce7b6bb7e5c05602aa8c308d0c4">NULL</a>); 130 void pack(NetConnection *, BitStream *bstream); 131 void write(NetConnection *, BitStream *bstream); 132 void unpack(NetConnection *, BitStream *bstream); 133 void process(NetConnection *); 134 DECLARE_CONOBJECT(Sim3DAudioEvent); 135}; 136 137 138//---------------------------------------------------------------------------- 139// used to set the crc for the current mission (mission lighting) 140//---------------------------------------------------------------------------- 141class SetMissionCRCEvent : public NetEvent 142{ 143 private: 144 U32 mCrc; 145 146 public: 147 typedef NetEvent Parent; 148 SetMissionCRCEvent(U32 crc = 0xffffffff) 149 { mCrc = crc; } 150 void pack(NetConnection *, BitStream * bstream) 151 { bstream->write(mCrc); } 152 void write(NetConnection * con, BitStream * bstream) 153 { pack(con, bstream); } 154 void unpack(NetConnection *, BitStream * bstream) 155 { bstream->read(&mCrc); } 156 void process(NetConnection * con) 157 { static_cast<GameConnection*>(con)->setMissionCRC(mCrc); } 158 159 DECLARE_CONOBJECT(SetMissionCRCEvent); 160}; 161 162#endif 163