halflife25-sdk/game_shared/simple_checksum.h
2013-08-30 13:34:05 -07:00

25 lines
642 B
C

// simple_checksum.h
// Functions to compute a simple checksum value for a file
// Author: Michael S. Booth, Turtle Rock Studios (www.turtlerockstudios.com), September 2003
#ifndef _SIMPLE_CHECKSUM_H_
#define _SIMPLE_CHECKSUM_H_
/**
* Compute a simple checksum for the given data.
* Each byte in the data is multiplied by its position to track re-ordering changes
*/
inline unsigned int ComputeSimpleChecksum( const unsigned char *dataPointer, int dataLength )
{
unsigned int checksum = 0;
for( int i=1; i<=dataLength; ++i )
{
checksum += (*dataPointer) * i;
++dataPointer;
}
return checksum;
}
#endif // _SIMPLE_CHECKSUM_H_