Cube  Diff

Differences From Artifact [f35a650122]:

To Artifact [3c6f02e0b1]:


166
167
168
169
170
171
172
173
174


175
176
177
178
179
180
181
166
167
168
169
170
171
172


173
174
175
176
177
178
179
180
181







-
-
+
+







// 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.

void
save_world(OFString *mname)
{
	resettagareas(); // wouldn't be able to reproduce tagged areas
	                 // otherwise
	// wouldn't be able to reproduce tagged areas otherwise
	resettagareas();
	voptimize();
	toptimize();
	if (mname.length == 0)
		mname = getclientmap();
	setnames(mname);
	backup(cgzname, bakname);
	gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215










216
217
218
219
220
221
222
199
200
201
202
203
204
205










206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222







-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+







				e.type, e.attr2, e.attr3, e.attr4 };
			endianswap(&tmp, sizeof(short), 4);
			gzwrite(f, &tmp, sizeof(struct persistent_entity));
		}
	}
	struct sqr *t = NULL;
	int sc = 0;
#define spurge                          \
	while (sc) {                    \
		gzputc(f, 255);         \
		if (sc > 255) {         \
			gzputc(f, 255); \
			sc -= 255;      \
		} else {                \
			gzputc(f, sc);  \
			sc = 0;         \
		}                       \
#define spurge				\
	while (sc) {			\
		gzputc(f, 255);		\
		if (sc > 255) {		\
			gzputc(f, 255);	\
			sc -= 255;	\
		} else {		\
			gzputc(f, sc);	\
			sc = 0;		\
		}			\
	}
	for (int k = 0; k < cubicsize; k++) {
		struct sqr *s = &world[k];
#define c(f) (s->f == t->f)
		// 4 types of blocks, to compress a bit:
		// 255 (2): same as previous block + count
		// 254 (3): same as previous, except light // deprecated
258
259
260
261
262
263
264


265
266

267
268
269
270
271
272
273
274
258
259
260
261
262
263
264
265
266
267

268

269
270
271
272
273
274
275







+
+

-
+
-







	settagareas();
}

COMMAND(savemap, ARG_1STR, ^ (OFString *mname) {
	save_world(mname);
})

// still supports all map formats that have existed since the earliest cube
// betas!
void
load_world(OFString *mname) // still supports all map formats that have existed
load_world(OFString *mname)
                            // since the earliest cube betas!
{
	stopifrecording();
	cleardlights();
	pruneundos(0);
	setnames(mname);
	gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding],
	    "rb9");