SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VariableListDeltaTracker.cpp
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
16 #include "slikenet/VariableListDeltaTracker.h"
17
18 using namespace SLNet;
19
20 VariableListDeltaTracker::VariableListDeltaTracker() {nextWriteIndex=0;}
21 VariableListDeltaTracker::~VariableListDeltaTracker()
22 {
23 unsigned int i;
24 for (i=0; i < variableList.Size(); i++)
25 rakFree_Ex(variableList[i].lastData,_FILE_AND_LINE_);
26 }
27
28 // Call before using a series of WriteVar
29 void VariableListDeltaTracker::StartWrite(void) {nextWriteIndex=0;}
30
31 void VariableListDeltaTracker::FlagDirtyFromBitArray(unsigned char *bArray)
32 {
33 unsigned short readOffset=0;
34 for (readOffset=0; readOffset < variableList.Size(); readOffset++)
35 {
36 bool result = ( bArray[ readOffset >> 3 ] & ( 0x80 >> ( readOffset & 7 ) ) ) !=0;
37
38 if (result==true)
39 variableList[readOffset].isDirty=true;
40 }
41 }
42 VariableListDeltaTracker::VariableLastValueNode::VariableLastValueNode()
43 {
44 lastData=0;
45 }
46 VariableListDeltaTracker::VariableLastValueNode::VariableLastValueNode(const unsigned char *data, int _byteLength)
47 {
48 lastData=(char*) rakMalloc_Ex(_byteLength,_FILE_AND_LINE_);
49 memcpy(lastData,data,_byteLength);
50 byteLength=_byteLength;
51 isDirty=false;
52 }
53 VariableListDeltaTracker::VariableLastValueNode::~VariableLastValueNode()
54 {
55 }