--- deliantra/server/common/image.C 2007/01/19 17:50:10 1.13 +++ 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 @@ -46,16 +48,10 @@ unsigned int number; }; -void free (bmappair *); // guard to catch free when delete should be used - static struct bmappair *xbm = NULL; -/* Following can just as easily be pointers, but - * it is easier to keep them like this. - */ facetile *blank_face, *dark_faces[3], *empty_face, *smooth_face; - /* nroffiles is the actual number of bitmaps defined. * nrofpixmaps is the number of bitmaps loaded. With * the automatic generation of the bmaps file, this is now equal @@ -72,14 +68,12 @@ /** * id is the face to smooth, smooth is the 16x2 face used to smooth id. */ -struct smoothing:zero_initialised +struct smoothing : zero_initialised { uint16 id; uint16 smooth; }; -void free (smoothing *); // guard to catch free when delete should be used - /** * Contains all defined smoothing entries. smooth is an array of nrofsmooth * entries. It is sorted by smooth[].id. @@ -234,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) @@ -264,6 +258,7 @@ LOG (llevDebug, "Warning, syntax error: %s\n", buf); continue; } + value = atoi (p); xbm[nroffiles].name = strdup (q); @@ -274,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); @@ -306,10 +294,9 @@ new_faces[i].visibility = 0; new_faces[i].magicmap = 255; } + for (i = 0; i < nroffiles; i++) - { - new_faces[xbm[i].number].name = xbm[i].name; - } + new_faces[xbm[i].number].name = xbm[i].name; // non-pod datatype, likely not allowed qsort (xbm, nroffiles, sizeof (struct bmappair), (int (*)(const void *, const void *)) compar); @@ -339,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 @@ -386,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)