Debian Codegraph @

src/common/d2char_checksum.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2000,2001 Onlyer ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
19 #include "d2char_checksum.h"cxx . . $ `<file>/src/common/d2char_checksum.h`/
20 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
21
22 namespace pvpgncxx . . $ pvpgn/
23 {
24
25 extern int d2charsave_checksumcxx . . $ pvpgn/d2charsave_checksum(eb174da03ea1718f).(unsigned char const * data, unsigned int len, unsigned int offset)
26 {
27 int checksum;
28 unsigned int i;
29 unsigned int ch;
30
31 if (!data) return 0;
32 checksum = 0;
33 for (i = 0; i < len; i++) {
34 if (i >= offset && i < offset + sizeof(int)) ch = 0;
35 else ch = *data;
36 ch += (checksum < 0);
37 checksum = 2 * checksum + ch;
38 data++;
39 }
40 return checksum;
41 }
42
43 }