Cube  Diff

Differences From Artifact [04f91a12de]:

To Artifact [96d53bd5cb]:


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
24
25
26
27
28
29
30



31
32
33
34
35
36
37







-
-
-







		strcpy_s(mapname, name);
	}
	sprintf_s(cgzname)("packages/%s/%s.cgz", pakname, mapname);
	sprintf_s(bakname)(
	    "packages/%s/%s_%d.BAK", pakname, mapname, lastmillis);
	sprintf_s(pcfname)("packages/%s/package.cfg", pakname);
	sprintf_s(mcfname)("packages/%s/%s.cfg", pakname, mapname);

	path(cgzname);
	path(bakname);
}

// the optimize routines below are here to reduce the detrimental effects of
// messy mapping by setting certain properties (vdeltas and textures) to
// neighbouring values wherever there is no visible difference. This allows the
// mipmapper to generate more efficient mips. the reason it is done on save is
// to reduce the amount spend in the mipmapper (as that is done in realtime).
133
134
135
136
137
138
139
140
141


142

143

144
145
146
147
148
149

150
151
152
153
154
155
156
130
131
132
133
134
135
136


137
138
139
140

141




142

143
144
145
146
147
148
149
150







-
-
+
+

+
-
+
-
-
-
-

-
+







		return;
	}
	fwrite(mdata, 1, msize, f);
	fclose(f);
	conoutf(@"wrote map %s as file %s", mname, cgzname);
}

uchar *
readmap(const char *mname, int *msize)
OFData *
readmap(OFString *mname)
{
	@autoreleasepool {
	setnames(mname);
		setnames(mname.UTF8String);
	uchar *mdata = (uchar *)loadfile(cgzname, msize);
	if (!mdata) {
		conoutf(@"could not read map %s", cgzname);
		return NULL;
	}
	return mdata;
	return [OFData dataWithContentsOfFile:mname];
}

// save map as .cgz file. uses 2 layers of compression: first does simple
// run-length encoding and leaves out data for certain kinds of cubes, then zlib
// removes the last bits of redundancy. Both passes contribute greatly to the
// miniscule map sizes.

358
359
360
361
362
363
364
365

366
367
368
369
370
371
372
352
353
354
355
356
357
358

359
360
361
362
363
364
365
366







-
+







		if (!SOLID(s))
			texuse[s->utex] = texuse[s->ftex] = texuse[s->ctex] = 1;
	}
	gzclose(f);
	calclight();
	settagareas();
	int xs, ys;
	loopi(256) if (texuse) lookuptexture(i, xs, ys);
	loopi(256) if (texuse) lookuptexture(i, &xs, &ys);
	conoutf(@"read map %s (%d milliseconds)", cgzname,
	    SDL_GetTicks() - lastmillis);
	conoutf(@"%s", hdr.maptitle);
	startmap(mname);
	loopl(256)
	{
		@autoreleasepool {