Differences From Artifact [f35a650122]:
- File
src/worldio.m
— part of check-in
[75e920ae30]
at
2025-03-29 14:25:43
on branch trunk
— Switch from clang-format to manual formatting
clang-format does too many weird things. (user: js, size: 10161) [annotate] [blame] [check-ins using]
To Artifact [3c6f02e0b1]:
- File src/worldio.m — part of check-in [c634a689e7] at 2025-03-29 17:13:40 on branch trunk — More style fixes (user: js, size: 10013) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
166 167 168 169 170 171 172 | // 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) { | | | | 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) { // 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 | 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; | | | | | | | | | | | | 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; \ } \ } 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 | settagareas(); } COMMAND(savemap, ARG_1STR, ^ (OFString *mname) { save_world(mname); }) void | > > | < | 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) { stopifrecording(); cleardlights(); pruneundos(0); setnames(mname); gzFile f = gzopen([cgzname cStringWithEncoding: OFLocale.encoding], "rb9"); |
︙ | ︙ |