+
+ if (cl_stainmaps.integer)
+ {
+ // allocate stainmaps for permanent marks on walls
+ int stainmapsize = 0;
+ unsigned char *stainsamples = NULL;
+ for (surfacenum = 0, surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, surface++)
+ {
+ ssize = (surface->lightmapinfo->extents[0] >> 4) + 1;
+ tsize = (surface->lightmapinfo->extents[1] >> 4) + 1;
+ stainmapsize += ssize * tsize * 3;
+ }
+ // allocate and clear to white
+ stainsamples = (unsigned char *)Mem_Alloc(loadmodel->mempool, stainmapsize);
+ memset(stainsamples, 255, stainmapsize);
+ // assign pointers
+ for (surfacenum = 0, surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, surface++)
+ {
+ ssize = (surface->lightmapinfo->extents[0] >> 4) + 1;
+ tsize = (surface->lightmapinfo->extents[1] >> 4) + 1;
+ surface->lightmapinfo->stainsamples = stainsamples;
+ stainsamples += ssize * tsize * 3;
+ }
+ }