VariableListDeltaTracker.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * 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. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. #include "VariableListDeltaTracker.h"
  11. using namespace RakNet;
  12. VariableListDeltaTracker::VariableListDeltaTracker() {nextWriteIndex=0;}
  13. VariableListDeltaTracker::~VariableListDeltaTracker()
  14. {
  15. unsigned int i;
  16. for (i=0; i < variableList.Size(); i++)
  17. rakFree_Ex(variableList[i].lastData,_FILE_AND_LINE_);
  18. }
  19. // Call before using a series of WriteVar
  20. void VariableListDeltaTracker::StartWrite(void) {nextWriteIndex=0;}
  21. void VariableListDeltaTracker::FlagDirtyFromBitArray(unsigned char *bArray)
  22. {
  23. unsigned short readOffset=0;
  24. for (readOffset=0; readOffset < variableList.Size(); readOffset++)
  25. {
  26. bool result = ( bArray[ readOffset >> 3 ] & ( 0x80 >> ( readOffset & 7 ) ) ) !=0;
  27. if (result==true)
  28. variableList[readOffset].isDirty=true;
  29. }
  30. }
  31. VariableListDeltaTracker::VariableLastValueNode::VariableLastValueNode()
  32. {
  33. lastData=0;
  34. }
  35. VariableListDeltaTracker::VariableLastValueNode::VariableLastValueNode(const unsigned char *data, int _byteLength)
  36. {
  37. lastData=(char*) rakMalloc_Ex(_byteLength,_FILE_AND_LINE_);
  38. memcpy(lastData,data,_byteLength);
  39. byteLength=_byteLength;
  40. isDirty=false;
  41. }
  42. VariableListDeltaTracker::VariableLastValueNode::~VariableLastValueNode()
  43. {
  44. }
粤ICP备19079148号