Emergency 20 Dokumentation  4.2.0
ProtocolHelper.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
15 
16 
17 //[-------------------------------------------------------]
18 //[ Forward declarations ]
19 //[-------------------------------------------------------]
20 namespace qsf
21 {
22  namespace game
23  {
24  class BitStream;
25  }
26 }
27 
28 
29 //[-------------------------------------------------------]
30 //[ Namespace ]
31 //[-------------------------------------------------------]
32 namespace em5
33 {
34  namespace multiplayer
35  {
36 
37 
38  //[-------------------------------------------------------]
39  //[ Classes ]
40  //[-------------------------------------------------------]
46  {
47 
48 
49  //[-------------------------------------------------------]
50  //[ Public static methods ]
51  //[-------------------------------------------------------]
52  public:
53  static uint16 getProtocolVersion();
54 
68  static void writeHeader(qsf::game::BitStream& bitStream, uint32 payloadSize);
69 
88  static bool readAndCheckHeader(const qsf::game::BitStream& bitStream, uint16& protocolVersion, uint32& payloadSize);
89 
102  static bool checkPayloadDataSize(const qsf::game::BitStream& bitStream, uint32 payloadSize);
103 
116  static bool writePayloadData(qsf::game::BitStream& bitStream, const qsf::game::BitStream& payloadData);
117 
132  static bool readPayloadData(const qsf::game::BitStream& bitStream, qsf::game::BitStream& payloadData, uint32 payloadSize);
133 
148  static bool writeOperationMessage(qsf::game::BitStream& bitStream, const OperationMessage& operationMessage, const qsf::game::BitStream& operationMessageData);
149 
162  static bool readOperationMessageType(const qsf::game::BitStream& bitStream, OperationMessage& operationMessage);
163 
178  static bool readOperationMessage(const qsf::game::BitStream& bitStream, OperationMessage& operationMessage, qsf::game::BitStream& operationMessageData);
179 
192  static bool writeClientJoinRequestOperationMessageData(qsf::game::BitStream& bitStream, const JoinRequestData& joinRequestData);
193 
206  static bool readClientJoinRequestOperationMessageData(const qsf::game::BitStream& bitStream, JoinRequestData& joinRequestData);
207 
220  // TODO(sw) Add additional data for the join response, as e.g. which map
221  static bool writeServerJoinResponseOperationMessageData(qsf::game::BitStream& bitStream, const JoinResponseData& joinResponseData);
222 
236  static bool writeServerJoinResponseWithoutAdditionalDataOperationMessageData(qsf::game::BitStream& bitStream, const JoinResponse& joinResponse);
237 
250  // TODO(sw) Add additional data for the join request, as game mod string and the content checksums
251  static bool readServerJoinResponseOperationMessageData(const qsf::game::BitStream& bitStream, JoinResponseData& joinResponseData);
252 
262  static bool writeReadyForGameOperationMessageData(qsf::game::BitStream& bitStream, const bool readyState);
263 
273  static bool readReadyForGameOperationMessageData(const qsf::game::BitStream& bitStream, bool& readyState);
274 
284  static bool writeUserDataChangedOperationMessageData(qsf::game::BitStream& bitStream, const uint32 userData);
285 
295  static bool readUserDataChangedOperationMessageData(const qsf::game::BitStream& bitStream, uint32& userData);
296 
304  static bool writeServerLoadMapOperationMessageData(qsf::game::BitStream& bitStream);
305 
313  static bool writeClientMapLoadedOperationMessageData(qsf::game::BitStream& bitStream);
314 
322  static bool writeServerGameStartOperationMessageData(qsf::game::BitStream& bitStream);
323 
336  static bool writeServerPlayerJoinedOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<SessionBase::PlayerInfo>& playerList);
337 
350  static bool readServerPlayerJoinedOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<SessionBase::PlayerInfo>& playerList);
351 
364  static bool writeServerPlayerLeftOperationMessageData(qsf::game::BitStream& bitStream, uint32 playerIndex);
365 
378  static bool readServerPlayerLeftOperationMessageData(const qsf::game::BitStream& bitStream, uint32& playerIndex);
379 
394  static bool writeServerPlayerChangedReadyStateOperationMessageData(qsf::game::BitStream& bitStream, uint32 playerIndex, bool isReady);
395 
410  static bool readServerPlayerChangedReadyStateOperationMessageData(const qsf::game::BitStream& bitStream, uint32& playerIndex, bool& isReady);
411 
426  static bool writeServerPlayerChangedUserDataOperationMessageData(qsf::game::BitStream& bitStream, uint32 playerIndex, uint32 userData);
427 
442  static bool readServerPlayerChangedUserDataOperationMessageData(const qsf::game::BitStream& bitStream, uint32& playerIndex, uint32& userData);
443 
456  static bool writeCreateEntityFromPrefabOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<EntityCreatedFromPrefabData>& createdEntitiesList, int32 currentTickCount);
457 
470  static bool readCreateEntityFromPrefabOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<EntityCreatedFromPrefabData>& createdEntitiesList, int32& currentTickCount);
471 
484  static bool writeDestroyEntityOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<uint64>& destroyedEntityIdsList, int32 currentTickCount);
485 
498  static bool readDestroyEntityOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<uint64>& destroyedEntityIdsList, int32& currentTickCount);
499 
512  static bool writeUnitSpawnedOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<UnitSpawnedData>& spawnedUnitDataList, int32 currentTickCount);
513 
526  static bool readUnitSpawnedOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<UnitSpawnedData>& spawnedUnitDataList, int32& currentTickCount);
527 
540  static bool writeUnitSpawnedPlayerUpdateSelectionOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<UnitSpawnedPlayerUpdateSelectionData>& spawnedUnitPlayerUpdateSelectionDataList, int32 currentTickCount);
541 
554  static bool readUnitSpawnedPlayerUpdateSelectionOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<UnitSpawnedPlayerUpdateSelectionData>& spawnedUnitPlayerUpdateSelectionDataList, int32& currentTickCount);
555 
568  static bool writeClientOrderedUnitOperationMessageData(qsf::game::BitStream& bitStream, const OrderUnitData& orderedUnitData);
569 
582  static bool readClientOrderedUnitOperationMessageData(const qsf::game::BitStream& bitStream, OrderUnitData& orderedUnitData);
583 
596  static bool writeClientCommandExecutionOperationMessageData(qsf::game::BitStream& bitStream, const CommandExecutionData& commandData);
597 
610  static bool readClientCommandExecutionOperationMessageData(const qsf::game::BitStream& bitStream, CommandExecutionData& commandData);
611 
624  static bool writeServerCommandExecutionResponseOperationMessageData(qsf::game::BitStream& bitStream, const CommandExecutionResult& commandData);
625 
638  static bool readServerCommandExecutionResponseOperationMessageData(const qsf::game::BitStream& bitStream, CommandExecutionResult& commandData);
639 
652  static bool writeFreeplayEventUpdateOperationMessageData(qsf::game::BitStream& bitStream, const std::unordered_map<uint32, FreeplayEventData>& updatedFreeplayEventList, int32 currentTickCount);
653 
666  static bool readFreeplayEventUpdateOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<FreeplayEventData>& updatedFreeplayEventList, int32& currentTickCount);
667 
680  static bool writeChatMessageOperationMessageData(qsf::game::BitStream& bitStream, const SessionBase::ChatMessage& chatMessage);
681 
694  static bool readChatMessageOperationMessageData(const qsf::game::BitStream& bitStream, SessionBase::ChatMessage& chatMessage);
695 
708  static bool writePlayerScoreChangedOperationMessageData(qsf::game::BitStream& bitStream, const boost::container::flat_map<uint32, uint32>& playerScoreList, int32 currentTickCount);
709 
722  static bool readPlayerScoreChangedOperationMessageData(const qsf::game::BitStream& bitStream, boost::container::flat_map<uint32, uint32>& playerScoreList, int32& currentTickCount);
723 
736  static bool writeGameModeUpdateOperationMessageData(qsf::game::BitStream& bitStream, const GameModeUpdateData& gameModeUpdateData, int32 currentTickCount);
737 
750  static bool readGameModeUpdateOperationMessageData(const qsf::game::BitStream& bitStream, GameModeUpdateData& gameModeUpdateData, int32& currentTickCount);
751 
764  static bool writeNewHintsOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<NewHintData>& newHintList, int32 currentTickCount);
765 
778  static bool readNewHintsOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<NewHintData>& newHintList, int32& currentTickCount);
779 
792  static bool writeMinimapMessagesOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<MinimapMessageData>& minimapMessageList, int32 currentTickCount);
793 
806  static bool readMinimapMessagesOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<MinimapMessageData>& minimapMessageList, int32& currentTickCount);
807 
820  static bool writeMinimapIconMessagesOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<MinimapIconMessageData>& minimapMessageList, int32 currentTickCount);
821 
834  static bool readMinimapIconMessagesOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<MinimapIconMessageData>& minimapMessageList, int32& currentTickCount);
835 
848  static bool writeAudioUpdatedMessagesOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<AudioUpdateData>& changedAudioList, int32 currentTickCount);
849 
862  static bool readAudioUpdatedOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<AudioUpdateData>& changedAudioList, int32& currentTickCount);
863 
876  static bool writeLayerChangedOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<LayerChangedData>& changedLayerList, int32 currentTickCount);
877 
890  static bool readLayerChangedOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<LayerChangedData>& changedLayerList, int32& currentTickCount);
891 
904  static bool writeNewFireHoseOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<CreateFireHoseData>& newFirehosesList, int32 currentTickCount);
905 
918  static bool readNewFireHoseOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<CreateFireHoseData>& newFirehosesList, int32& currentTickCount);
919 
932  static bool writeSpawnParticleOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<SpawnParticleData>& spawnParticleList, int32 currentTickCount);
933 
946  static bool readSpawnParticleOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<SpawnParticleData>& spawnParticleList, int32& currentTickCount);
947 
960  static bool writeClientCameraPositionOperationMessageData(qsf::game::BitStream& bitStream, const glm::vec3& position);
961 
974  static bool readClientCameraPositionOperationMessageData(const qsf::game::BitStream& bitStream, glm::vec3& position);
975 
988  static bool writeServerPingOperationMessageData(qsf::game::BitStream& bitStream, const ServerPingData& pingData);
989 
1002  static bool readServerPingOperationMessageData(const qsf::game::BitStream& bitStream, ServerPingData& pingData);
1003 
1016  static bool writeClientPingAcknowledgeOperationMessageData(qsf::game::BitStream& bitStream, const ClientPingAcknowledgeData& pingAcknowledgeData);
1017 
1030  static bool readClientPingAcknowledgeOperationMessageData(const qsf::game::BitStream& bitStream, ClientPingAcknowledgeData& pingAcknowledgeData);
1031 
1044  static bool writeFadeEntityOperationMessageData(qsf::game::BitStream& bitStream, const std::vector<FadeEntityData>& fadeEntityDataList, int32 currentTickCount);
1045 
1058  static bool readFadeEntityOperationMessageData(const qsf::game::BitStream& bitStream, std::vector<FadeEntityData>& fadeEntityDataList, int32& currentTickCount);
1059 
1072  static bool writeMinimapPingOperationMessageData(qsf::game::BitStream& bitStream, const MinimapPingData& minimapPingData, int32 currentTickCount);
1073 
1089  static bool readMinimapPingOperationMessageData(const qsf::game::BitStream& bitStream, MinimapPingData& minimapPingData, int32& currentTickCount);
1090 
1105  static bool writeOperationMessageAsSingleMessage(qsf::game::BitStream& bitStream, const OperationMessage& operationMessage, const qsf::game::BitStream& operationMessagePayload);
1106 
1119  static bool writeOperationMessageWithoutAdditionalPayloadAsSingleMessage(qsf::game::BitStream& bitStream, const OperationMessage& operationMessage);
1120 
1121 
1122  };
1123 
1124 
1125 //[-------------------------------------------------------]
1126 //[ Namespace ]
1127 //[-------------------------------------------------------]
1128  } // multiplayer
1129 } // em5
Definition: ActionPriority.h:13
Definition: OperationMessages.h:640
Definition: OperationMessages.h:567
Definition: OperationMessages.h:255
void writeHeader(boost::property_tree::ptree &root, const std::string &type, unsigned int version)
unsigned int uint32
Definition: PlatformTypes.h:181
Definition: OperationMessages.h:142
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: SessionBase.h:139
Definition: OperationMessages.h:213
OperationMessage
EMERGENCY 5 multiplayer operation message types.
Definition: OperationMessages.h:51
Definition: OperationMessages.h:346
Game bit stream class (just a wrapper for linnet bit stream)
Definition: BitStream.h:40
Definition: PickupPersonByParamedicAction.h:21
Definition: OperationMessages.h:233
signed int int32
Definition: PlatformTypes.h:180
JoinResponse
Definition: OperationMessages.h:117
unsigned short uint16
Definition: PlatformTypes.h:178
Definition: OperationMessages.h:553
Definition: OperationMessages.h:127
EMERGENCY 5 multiplayer protocol helper.
Definition: ProtocolHelper.h:45