- if(!dedup || (tid = matchtile(img, tileoffs, th)) == -1) {
- tmap->map[tileno] = tileno;
- tileoffs += th; /* destination Y offset, inc by th for every tile */
+ if(dedup) {
+ if((tid = matchtile(img, tileoffs, th)) == -1) {
+ if(tmap) {
+ tmap->map[tileno++] = tileoffs / th;
+ }
+ tileoffs += th; /* destination Y offset, inc by th for every tile */
+ } else {
+ if(tmap) {
+ tmap->map[tileno++] = tid;
+ }
+ }