From 304f02f926d706f697d3b54b3d72cf9adf0cd346 Mon Sep 17 00:00:00 2001 From: "Peter S. May" Date: Thu, 11 Jul 2002 23:24:35 +0000 Subject: [PATCH] New GetHashForString functionality added. --- stepmania/src/RageUtil.cpp | 22 +++++++++++++--------- stepmania/src/StepMania.dsp | 8 ++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index e202783d43..402a19b7b2 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -7,11 +7,12 @@ Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford + Peter S. May (GetHashForString implementation) ----------------------------------------------------------------------------- */ #include "RageUtil.h" - +#include "RageCRC32.h" // Backend for GetHashForString bool IsAnInt( LPCTSTR s ) @@ -285,15 +286,18 @@ void GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bRe ::FindClose( hFind ); } -int GetHashForString( CString s ) +//----------------------------------------------------------------------------- +// Name: GetHashForString( CString s ) +// Desc: This new version of GetHashForString uses a stronger hashing algorithm +// than the former, assuring to a greater degree that two distinct +// strings do not produce the same result. +// The hashing algorithm is a modified CRC-32 (modified in that the +// characters in the CString are recast as unsigned char and that the +// unsigned int result from the hash is recast as a signed int). +//----------------------------------------------------------------------------- +int GetHashForString ( CString s ) { - int hash = 0; - for( int i=0; i