SLikeNet  0.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CheckSum.h
Go to the documentation of this file.
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  * 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 
20 
21 #ifndef __CHECKSUM_H
22 #define __CHECKSUM_H
23 
24 #include "memoryoverride.h"
25 
27 class CheckSum
28 {
29 
30 public:
31 
33 
35  {
36  Clear();
37  }
38 
39  void Clear()
40  {
41  sum = 0;
42  r = 55665;
43  c1 = 52845;
44  c2 = 22719;
45  }
46 
47  void Add ( unsigned int w );
48 
49 
50  void Add ( unsigned short w );
51 
52  void Add ( unsigned char* b, unsigned int length );
53 
54  void Add ( unsigned char b );
55 
56  unsigned int Get ()
57  {
58  return sum;
59  }
60 
61 protected:
62  unsigned short r;
63  unsigned short c1;
64  unsigned short c2;
65  unsigned int sum;
66 };
67 
68 #endif