Overview
Comment: | Clean up file handling |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
3d55e077f74fc1c036e856cc4fdf0ae3 |
User & Date: | js on 2025-03-05 21:29:54.626 |
Other Links: | manifest | tags |
Context
2025-03-05
| ||
21:55 | Clean up console output functions check-in: 003b06901f user: js tags: trunk | |
21:29 | Clean up file handling check-in: 3d55e077f7 user: js tags: trunk | |
01:15 | Convert texture pixel format if necessary check-in: 12641927d9 user: js tags: trunk | |
Changes
Modified src/Cube.mm
from [a97b4669e3]
to [ee205df0bd].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | + | // main.cpp: initialisation & main loop #include "cube.h" OF_APPLICATION_DELEGATE(Cube) VARF(gamespeed, 10, 100, 1000, if (multiplayer()) gamespeed = 100); VARP(minmillis, 0, 5, 1000); @implementation Cube { int _width, _height; OFIRI *_userDataIRI; } + (Cube *)sharedInstance { return (Cube *)OFApplication.sharedApplication.delegate; } |
︙ | |||
112 113 114 115 116 117 118 119 | 113 114 115 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | + + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | SDL_SetRelativeMouseMode(SDL_TRUE); SDL_ShowCursor(0); log("gl"); gl_init(_width, _height); log("basetex"); _gameDataIRI = [OFFileManager.defaultManager currentDirectoryIRI]; _userDataIRI = [OFFileManager.defaultManager currentDirectoryIRI]; int xs, ys; |
︙ | |||
265 266 267 268 269 270 271 | 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 | + + - - - + + + + + + + + | memcpy(dest, (char *)image->pixels + 3 * _width * (_height - 1 - idx), 3 * _width); endianswap(dest, 3, _width); } @autoreleasepool { OFString *path = [OFString |
︙ |
Modified src/clientextras.mm
from [138c74a711]
to [8bec7c55fe].
︙ | |||
165 166 167 168 169 170 171 | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | - - + + - + - - - + + - | { @autoreleasepool { if (mapname.length > 0) save_world(mapname); changemap(mapname); mapname = getclientmap(); int mapsize; |
︙ |
Modified src/command.mm
from [926958b6fe]
to [9583e64f42].
︙ | |||
553 554 555 556 557 558 559 | 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 | + - - + + - - + + - - + + + + + | completeidx = 0; } bool execfile(OFString *cfgfile) { @autoreleasepool { OFMutableData *data; |
︙ |
Modified src/cube.h
from [25a73b021e]
to [f1d0278915].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | + | // one big bad include file for the whole engine... nasty! #import <ObjFW/ObjFW.h> #define gamma gamma__ #include <SDL2/SDL.h> #undef gamma #include "tools.h" @interface Cube : OFObject <OFApplicationDelegate> @property (class, readonly, nonatomic) Cube *sharedInstance; @property (readonly, nonatomic) SDL_Window *window; @property (readonly, nonatomic) OFIRI *gameDataIRI; @property (nonatomic) bool repeatsKeys; @property (nonatomic) int framesInMap; @end enum // block types, order matters! { SOLID = 0, // entirely solid cube [only specifies wtex] |
︙ |
Modified src/protos.h
from [17a165017a]
to [8b1e3ca44e].
︙ | |||
40 41 42 43 44 45 46 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - + - - + | extern char *getservername(int n); extern void writeservercfg(); // rendergl extern void gl_init(int w, int h); extern void cleangl(); extern void gl_drawframe(int w, int h, float curfps); |
︙ | |||
181 182 183 184 185 186 187 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - + | int type, int fade, OFVector3D &from, OFVector3D &to); extern void render_particles(int time); // worldio extern void save_world(OFString *fname); extern void load_world(char *mname); extern void writemap(char *mname, int msize, uchar *mdata); |
︙ |
Modified src/rendercubes.mm
from [bb9341fd13]
to [3909c7f58d].
︙ | |||
99 100 101 102 103 104 105 | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | - + | vertcheck(); if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; }; int sx, sy; |
︙ | |||
180 181 182 183 184 185 186 | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - + | vertcheck(); if (showm) { l3 = l1 = &sbright; l4 = l2 = &sdark; }; int sx, sy; |
︙ | |||
234 235 236 237 238 239 240 | 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | - + - + | render_2tris(sqr *h, sqr *s, int x1, int y1, int x2, int y2, int x3, int y3, sqr *l1, sqr *l2, sqr *l3) // floor/ceil tris on a corner cube { stripend(); vertcheck(); int sx, sy; |
︙ | |||
288 289 290 291 292 293 294 | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | - + | vertcheck(); if (showm) { l1 = &sbright; l2 = &sdark; }; int sx, sy; |
︙ | |||
348 349 350 351 352 353 354 | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | - + | if (wx1 < 0) return nquads; glDepthMask(GL_FALSE); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_SRC_COLOR); int sx, sy; |
︙ |
Modified src/renderextras.mm
from [4e49ca5579]
to [6ccf3a9b83].
︙ | |||
202 203 204 205 206 207 208 209 210 | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | + - + + + + + - - + + - + + + + + | } void loadsky(OFString *basename) { @autoreleasepool { static OFString *lastsky = @""; if ([lastsky isEqual:basename]) return; |
︙ |
Modified src/rendergl.mm
from [154658a1d9]
to [86ca5a8f24].
︙ | |||
69 70 71 72 73 74 75 | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | - + + - - - - - + + + + + + + - - - - - + + + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - - - - + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - + + + + + + - + - - - - - - - + + + + + + + + - - - + + + - - + + - + - + + | cleangl() { if (qsphere) gluDeleteQuadric(qsphere); } bool |
︙ | |||
185 186 187 188 189 190 191 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | - - + - - + + - - - - + + + + - - + + - - + + + + - + - - - - - - - - + + + + + + + + + + + - - + + + | @autoreleasepool { int num = curtexnum++, frame = (int)aframe.longLongValue; if (num < 0 || num >= 256 || frame < 0 || frame >= MAXFRAMES) return; mapping[num][frame] = 1; char *n = mapname[num][frame]; strcpy_s(n, name.UTF8String); |
︙ | |||
414 415 416 417 418 419 420 | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | - + | glMatrixMode(GL_MODELVIEW); transplayer(); glEnable(GL_TEXTURE_2D); int xs, ys; |
︙ |
Modified src/rendermd2.mm
from [1644c7ed89]
to [d83bc98847].
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | - + | } @property (nonatomic) MapModelInfo *mmi; @property (copy, nonatomic) OFString *loadname; @property (nonatomic) int mdlnum; @property (nonatomic) bool loaded; |
︙ | |||
75 76 77 78 79 80 81 | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 | - + - - - - - + + + + + + + + + + + - - + + + + - - + + - - - + + + - - + + + - - + + + - - - + + + - - - - + + + + - - - - - + + + + + - + - - + + - + + | { if (_glCommands) delete[] _glCommands; if (_frames) delete[] _frames; } |
︙ | |||
231 232 233 234 235 236 237 | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | + - - - - - + + + + + + + + + - + + - + | const int FIRSTMDL = 20; void delayedload(MD2 *m) { if (!m.loaded) { @autoreleasepool { OFString *path = [OFString |
︙ | |||
310 311 312 313 314 315 316 | 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | - + | if (isoccluded(player1->o.x, player1->o.y, x - rad, z - rad, rad * 2)) return; delayedload(m); int xs, ys; glBindTexture(GL_TEXTURE_2D, |
︙ |
Modified src/sound.mm
from [ee786c999c]
to [b06342c3fd].
︙ | |||
82 83 84 85 86 87 88 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - - - + + + + + - + + - + + + - + | music(OFString *name) { if (nosound) return; stopsound(); if (soundvol && musicvol) { @autoreleasepool { |
︙ | |||
226 227 228 229 230 231 232 | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | - - + + + - + + + - + + - - + + + - + + - - + + - + | lastsoundmillis = lastmillis; if (soundsatonce > 5) return; // avoid bursts of sounds with heavy packetloss // and in sp if (n < 0 || n >= samples.length()) { conoutf(@"unregistered sound: %d", n); return; |
Modified src/tools.h
from [fecbc01816]
to [257c91a25c].
︙ | |||
118 119 120 121 122 123 124 | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - - | formatstring(d, fmt, ap); \ va_end(ap); \ } #define sprintf_sdv(d, fmt) sprintf_sdlv(d, fmt, fmt) #define fast_f2nat(val) ((int)(val)) |
︙ |
Modified src/tools.mm
from [bc3e2d9f84]
to [06a94d32b1].
︙ | |||
96 97 98 99 100 101 102 | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | { static pool *p = NULL; return p ? p : (p = new pool()); }; ///////////////////////// misc tools /////////////////////// |
︙ |
Modified src/weapon.mm
from [53bbf8febc]
to [32ce1b4cac].
1 2 3 4 5 6 7 8 9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - - - - + + + + - + | // weapon.cpp: all shooting and effects code #include "cube.h" struct guninfo { short sound, attackdelay, damage, projspeed, part, kickamount; OFString *name; }; |
︙ |
Modified src/worldio.mm
from [04f91a12de]
to [96d53bd5cb].
︙ | |||
24 25 26 27 28 29 30 | 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); |
︙ | |||
133 134 135 136 137 138 139 | 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); } |
︙ | |||
358 359 360 361 362 363 364 | 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; |
︙ |