From 87c8f8ab06c01f3af4aed682ddbaac094064c4c8 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Thu, 16 Apr 2015 17:11:49 -0400 Subject: [PATCH] fix platform issues with chksum data types --- include/cfile.h | 2 +- src/cfile/cfile.cpp | 18 +++++++++--------- src/network/multi_pxo.cpp | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/cfile.h b/include/cfile.h index 4a3b1cb..565a7a2 100644 --- a/include/cfile.h +++ b/include/cfile.h @@ -516,7 +516,7 @@ int cf_chksum_long(CFILE *file, uint *chksum, int max_size = -1); ushort cf_add_chksum_short(ushort seed, const char *buffer, int size); // update cur_chksum with the chksum of the new_data of size new_data_size -unsigned long cf_add_chksum_long(unsigned long seed, const char *buffer, int size); +uint cf_add_chksum_long(uint seed, const char *buffer, int size); // convenient for misc checksumming purposes ------------------------------------------ diff --git a/src/cfile/cfile.cpp b/src/cfile/cfile.cpp index f8b6f62..6e08695 100644 --- a/src/cfile/cfile.cpp +++ b/src/cfile/cfile.cpp @@ -1254,7 +1254,7 @@ int cfputs(const char *str, CFILE *cfile) // CRC code for mission validation. given to us by Kevin Bentley on 7/20/98. Some sort of // checksumming code that he wrote a while ago. #define CRC32_POLYNOMIAL 0xEDB88320L -unsigned long CRCTable[256]; +uint CRCTable[256]; #define CF_CHKSUM_SAMPLE_SIZE 512 @@ -1262,9 +1262,9 @@ unsigned long CRCTable[256]; ushort cf_add_chksum_short(ushort seed, const char *buffer, int size) { const ubyte * ptr = (const ubyte *)buffer; - unsigned int sum1,sum2; + uint sum1,sum2; - sum1 = sum2 = (int)(seed); + sum1 = sum2 = (uint)(seed); while(size--) { sum1 += *ptr++; @@ -1273,16 +1273,16 @@ ushort cf_add_chksum_short(ushort seed, const char *buffer, int size) } sum2 %= 255; - return (unsigned short)((sum1<<8)+ sum2); + return (ushort)((sum1<<8)+ sum2); } // update cur_chksum with the chksum of the new_data of size new_data_size -unsigned long cf_add_chksum_long(unsigned long seed, const char *buffer, int size) +uint cf_add_chksum_long(uint seed, const char *buffer, int size) { - unsigned long crc; + uint crc; unsigned const char *p; - unsigned long temp1; - unsigned long temp2; + uint temp1; + uint temp2; p = (unsigned const char*)buffer; crc = seed; @@ -1299,7 +1299,7 @@ unsigned long cf_add_chksum_long(unsigned long seed, const char *buffer, int siz void cf_chksum_long_init() { int i,j; - unsigned long crc; + uint crc; for( i=0;i<=255;i++) { crc=i; diff --git a/src/network/multi_pxo.cpp b/src/network/multi_pxo.cpp index 3175a3d..6c27bc8 100644 --- a/src/network/multi_pxo.cpp +++ b/src/network/multi_pxo.cpp @@ -4008,8 +4008,8 @@ void multi_pxo_set_end_of_motd() Pxo_motd_read = 0; // do we have an old MOTD file laying around? If so, read it in and see if its the same - unsigned int old_chksum; - unsigned long new_chksum; + uint old_chksum; + uint new_chksum; // checksum the current motd new_chksum = cf_add_chksum_long(0, Pxo_motd, strlen(Pxo_motd)); @@ -4018,7 +4018,7 @@ void multi_pxo_set_end_of_motd() CFILE *in = cfopen("oldmotd.txt", "rb"); if(in != NULL){ // read the old checksum - cfread(&old_chksum, sizeof(old_chksum), 1, in); + old_chksum = cfread_uint(in); cfclose(in); // same checksum? no blink @@ -4032,7 +4032,7 @@ void multi_pxo_set_end_of_motd() CFILE *out = cfopen("oldmotd.txt", "wb", CFILE_NORMAL, CF_TYPE_DATA); if(out != NULL){ // write all the text - cfwrite(&new_chksum, sizeof(new_chksum), 1, out); + cfwrite_uint(new_chksum, out); // close the outfile cfclose(out); -- 2.39.2