forked from mirror/OpenTTD
(svn r11695) -Codechange: Converted the md5 algorithm to OOP
-Codechange: Adapt the md5 algorithm to the OpenTTD source
This commit is contained in:
@@ -32,8 +32,8 @@ GRFConfig *_grfconfig_static;
|
||||
static bool CalcGRFMD5Sum(GRFConfig *config)
|
||||
{
|
||||
FILE *f;
|
||||
md5_state_t md5state;
|
||||
md5_byte_t buffer[1024];
|
||||
Md5 checksum;
|
||||
uint8 buffer[1024];
|
||||
size_t len, size;
|
||||
|
||||
/* open the file */
|
||||
@@ -41,12 +41,11 @@ static bool CalcGRFMD5Sum(GRFConfig *config)
|
||||
if (f == NULL) return false;
|
||||
|
||||
/* calculate md5sum */
|
||||
md5_init(&md5state);
|
||||
while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, f)) != 0 && size != 0) {
|
||||
size -= len;
|
||||
md5_append(&md5state, buffer, len);
|
||||
checksum.Append(buffer, len);
|
||||
}
|
||||
md5_finish(&md5state, config->md5sum);
|
||||
checksum.Finish(config->md5sum);
|
||||
|
||||
FioFCloseFile(f);
|
||||
|
||||
|
Reference in New Issue
Block a user