--- deliantra/server/common/image.C 2007/02/15 15:43:36 1.16 +++ deliantra/server/common/image.C 2007/02/15 18:09:33 1.17 @@ -26,6 +26,8 @@ #include #include +#include "crc.h" + facetile *new_faces; /* bmappair and xbm are used when looking for the image id numbers @@ -226,8 +228,8 @@ FILE *fp; int value, nrofbmaps = 0, i; size_t l; + crc32 crc; - bmaps_checksum = 0; sprintf (buf, "%s/bmaps", settings.datadir); LOG (llevDebug, "Reading bmaps from %s...\n", buf); if ((fp = fopen (buf, "r")) == NULL) @@ -256,6 +258,7 @@ LOG (llevDebug, "Warning, syntax error: %s\n", buf); continue; } + value = atoi (p); xbm[nroffiles].name = strdup (q); @@ -266,25 +269,18 @@ * data, it does the job as it lets the client know if * the file has the same data or not. */ - rotate_right (bmaps_checksum); - bmaps_checksum += value & 0xff; - bmaps_checksum &= 0xffffffff; - - rotate_right (bmaps_checksum); - bmaps_checksum += (value >> 8) & 0xff; - bmaps_checksum &= 0xffffffff; + crc (value); + crc (value >> 8); + for (l = 0; l < strlen (q); l++) - { - rotate_right (bmaps_checksum); - bmaps_checksum += q[l]; - bmaps_checksum &= 0xffffffff; - } + crc (q [l]); xbm[nroffiles].number = value; nroffiles++; if (value >= nrofpixmaps) nrofpixmaps = value + 1; } + fclose (fp); LOG (llevDebug, "done (got %d/%d/%d)\n", nrofpixmaps, nrofbmaps, nroffiles); @@ -330,6 +326,8 @@ dark_faces[2] = &new_faces[FindFace (DARK_FACE3_NAME, 0)]; smooth_face = &new_faces[FindFace (SMOOTH_FACE_NAME, 0)]; + + bmaps_checksum = crc; } /* This returns an the face number of face 'name'. Number is constant @@ -377,7 +375,6 @@ FILE *fp; int smoothcount = 0; - bmaps_checksum = 0; sprintf (buf, "%s/smooth", settings.datadir); LOG (llevDebug, "Reading smooth from %s...\n", buf); if ((fp = fopen (buf, "r")) == NULL)