Cube  Diff

Differences From Artifact [96d53bd5cb]:

To Artifact [fcad2200c2]:


116
117
118
119
120
121
122
123
124

125

126

127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
		}
	}
}

// these two are used by getmap/sendmap.. transfers compressed maps directly

void
writemap(char *mname, int msize, uchar *mdata)
{

	setnames(mname);

	backup(cgzname, bakname);

	FILE *f = fopen(cgzname, "wb");
	if (!f) {
		conoutf(@"could not write map to %s", cgzname);
		return;
	}
	fwrite(mdata, 1, msize, f);
	fclose(f);
	conoutf(@"wrote map %s as file %s", mname, cgzname);
}

OFData *
readmap(OFString *mname)
{
	@autoreleasepool {
		setnames(mname.UTF8String);







|

>
|
>

>







|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
		}
	}
}

// these two are used by getmap/sendmap.. transfers compressed maps directly

void
writemap(OFString *mname, int msize, uchar *mdata)
{
	@autoreleasepool {
		setnames(mname.UTF8String);
	}
	backup(cgzname, bakname);

	FILE *f = fopen(cgzname, "wb");
	if (!f) {
		conoutf(@"could not write map to %s", cgzname);
		return;
	}
	fwrite(mdata, 1, msize, f);
	fclose(f);
	conoutf(@"wrote map %@ as file %s", mname, cgzname);
}

OFData *
readmap(OFString *mname)
{
	@autoreleasepool {
		setnames(mname.UTF8String);
237
238
239
240
241
242
243
244
245
246
247
248
249

250

251
252
253
254
255
256
257
		conoutf(@"wrote map file %s", cgzname);
		settagareas();
	}
}
COMMANDN(savemap, save_world, ARG_1STR)

void
load_world(char *mname) // still supports all map formats that have existed
                        // since the earliest cube betas!
{
	stopifrecording();
	cleardlights();
	pruneundos();

	setnames(mname);

	gzFile f = gzopen(cgzname, "rb9");
	if (!f) {
		conoutf(@"could not read map %s", cgzname);
		return;
	}
	gzread(f, &hdr, sizeof(header) - sizeof(int) * 16);
	endianswap(&hdr.version, sizeof(int), 4);







|
|




>
|
>







240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
		conoutf(@"wrote map file %s", cgzname);
		settagareas();
	}
}
COMMANDN(savemap, save_world, ARG_1STR)

void
load_world(OFString *mname) // still supports all map formats that have existed
                            // since the earliest cube betas!
{
	stopifrecording();
	cleardlights();
	pruneundos();
	@autoreleasepool {
		setnames(mname.UTF8String);
	}
	gzFile f = gzopen(cgzname, "rb9");
	if (!f) {
		conoutf(@"could not read map %s", cgzname);
		return;
	}
	gzread(f, &hdr, sizeof(header) - sizeof(int) * 16);
	endianswap(&hdr.version, sizeof(int), 4);