-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPacketHeader.cpp
More file actions
36 lines (29 loc) · 1.43 KB
/
Copy pathPacketHeader.cpp
File metadata and controls
36 lines (29 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "PacketHeader.h"
#include "bytesToDataTypeHelper.h"
#include <iostream>
void PacketHeader::convertBytesToObject(char* input, int index)
{
std::cout << " Size of bytes received: ";
std::cout << sizeof(input)/sizeof(char) << std::endl;
m_packetFormat = bytesToUInt16(input[index+1], input[index+0]);
m_packetVersion = int(input[index+2]);
m_packetId = int(input[index+3]);
m_sessionUID = bytesToUInt64(input[index+11], input[index+10], input[index+9], input[index+8], input[index+7], input[index+6], input[index+5], input[index+4]);
m_sessionTime = bytesToFloat(input[index+15], input[index+14], input[index+13], input[index+12]);
m_frameIdentifier = int(input[index+16]);
m_playerCarIndex = int(input[index+17]);
indexInput = index+17;
}
PacketHeader::PacketHeader(char input[], int index)
{
std::cout << " Size of bytes received: ";
std::cout << sizeof(input)/sizeof(char) << std::endl;
m_packetFormat = bytesToUInt16(input[index+1], input[index+0]);
m_packetVersion = int(input[index+2]);
m_packetId = int(input[index+3]);
m_sessionUID = bytesToUInt64(input[index+11], input[index+10], input[index+9], input[index+8], input[index+7], input[index+6], input[index+5], input[index+4]);
m_sessionTime = bytesToFloat(input[index+15], input[index+14], input[index+13], input[index+12]);
m_frameIdentifier = int(input[index+16]);
m_playerCarIndex = int(input[index+17]);
indexInput = index+17;
}