Comment: | More style fixes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c634a689e76e7c60fb8b685ea40cb999 |
User & Date: | js on 2025-03-29 17:13:40 |
Other Links: | manifest | tags |
2025-03-29
| ||
22:29 | Add variables with a getter / setter block check-in: cd2ac12a14 user: js tags: trunk | |
17:13 | More style fixes check-in: c634a689e7 user: js tags: trunk | |
14:25 | Switch from clang-format to manual formatting check-in: 75e920ae30 user: js tags: trunk | |
Modified src/Alias.h from [0fb6418ce5] to [c03f900e5c].
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 | - - + + - - + + | #import "Identifier.h" OF_ASSUME_NONNULL_BEGIN @interface Alias: Identifier @property (direct, copy, nonatomic) OFString *action; @property (readonly, nonatomic) bool persisted; + (instancetype)aliasWithName: (OFString *)name |
Modified src/Alias.m from [fe2a009013] to [99fa37b5c7].
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | - - + + - - + + - - + + | #import "Alias.h" @implementation Alias + (instancetype)aliasWithName: (OFString *)name |
︙ |
Modified src/Command.h from [f6eb8c644d] to [4155619926].
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | - - - - - - - - - + + + + + + + + + - - + + - - + + | #import "Identifier.h" OF_ASSUME_NONNULL_BEGIN |
Modified src/Command.m from [254356cb16] to [5f400a60e2].
︙ | |||
21 22 23 24 25 26 27 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - - + + - - + + - - + + | @implementation Command { id _block; } + (instancetype)commandWithName: (OFString *)name |
︙ |
Modified src/Cube.m from [67dd855e73] to [4173147859].
︙ | |||
123 124 125 126 127 128 129 | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - + - - - + + - | _height = 1080; } } log(@"video: mode"); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if ((_window = SDL_CreateWindow("cube engine", |
︙ | |||
240 241 242 243 244 245 246 | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | - - + + | [self quit]; break; case SDL_KEYDOWN: case SDL_KEYUP: if (_repeatsKeys || event.key.repeat == 0) keypress(event.key.keysym.sym, |
︙ | |||
301 302 303 304 305 306 307 | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | - + - + - - - + + - | - (void)screenshot { SDL_Surface *image; SDL_Surface *temp; if ((image = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, 24, |
︙ | |||
343 344 345 346 347 348 349 | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | - + | // failure exit void fatal(OFConstantString *s, ...) { va_list args; va_start(args, s); OFMutableString *msg = [[OFMutableString alloc] initWithFormat: s |
︙ |
Modified src/MD2.h from [25323c6c56] to [af445ff14a].
︙ | |||
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - - - - - - - - - + + + + + + + + + | @property (copy, nonatomic) OFString *loadname; @property (nonatomic) int mdlnum; @property (nonatomic) bool loaded; + (instancetype)md2; - (bool)loadWithIRI: (OFIRI *)IRI; - (void)renderWithLight: (OFColor *)light |
Modified src/MD2.m from [64d68c27a0] to [c2a1e1b6fe].
︙ | |||
65 66 67 68 69 70 71 | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | - + | - (bool)loadWithIRI: (OFIRI *)IRI { OFSeekableStream *stream; @try { stream = (OFSeekableStream *)[[OFIRIHandler handlerForIRI: IRI] openItemAtIRI: IRI |
︙ | |||
88 89 90 91 92 93 94 | 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 | - + - + | _frames = OFAllocMemory(header.numFrames, header.frameSize); } @catch (OFOutOfMemoryException *e) { return false; } [stream seekToOffset: header.offsetFrames whence: OFSeekSet]; [stream readIntoBuffer: _frames |
︙ | |||
136 137 138 139 140 141 142 | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - - - - - - - - - + + + + + + + + + | v->y = -(snap(sn, cv[1] * cf->scale[1]) + cf->translate[1]) / sc; v->z = (snap(sn, cv[2] * cf->scale[2]) + cf->translate[2]) / sc; } } - (void)renderWithLight: (OFColor *)light |
︙ |
Modified src/MapModelInfo.h from [9966a1ab68] to [1a4824d0f9].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - - - - + + + + - - - - + + + + | #import <ObjFW/ObjFW.h> OF_ASSUME_NONNULL_BEGIN OF_DIRECT_MEMBERS @interface MapModelInfo: OFObject @property (nonatomic) int rad, h, zoff, snap; @property (copy, nonatomic) OFString *name; + (instancetype)infoWithRad: (int)rad |
Modified src/MapModelInfo.m from [19135ee4c2] to [bd54b60804].
1 2 3 4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - - - - + + + + - - - - + + + + | #import "MapModelInfo.h" @implementation MapModelInfo + (instancetype)infoWithRad: (int)rad |
︙ |
Modified src/Monster.h from [ecb02516a6] to [09f03dc0a4].
︙ | |||
23 24 25 26 27 28 29 | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - - - - + + + + - - - - + + + + | + (void)restoreAll; + (void)resetAll; + (void)thinkAll; + (void)renderAll; // TODO: Move this somewhere else + (void)endSinglePlayerWithAllKilled: (bool)allKilled; + (instancetype)monsterWithType: (int)type |
Modified src/Monster.m from [911d4fb855] to [aa7be47ff2].
︙ | |||
19 20 21 22 23 24 25 | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | - - - - + + + + - - - - + + + + | + (OFMutableArray<Monster *> *)monsters { return monsters; } + (instancetype)monsterWithType: (int)type |
︙ | |||
72 73 74 75 76 77 78 | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | - - - - + + + + | { GUN_ICEBALL, 12, 250, 1, 0, 10, 400, 6, 18, 18, S_PAINH, S_DEATHH, @"a knight", @"monster/knight" }, { GUN_SLIMEBALL, 15, 100, 1, 0, 200, 400, 2, 13, 10, S_PAIND, S_DEATHD, @"a goblin", @"monster/goblin" }, }; - (instancetype)initWithType: (int)type |
︙ | |||
168 169 170 171 172 173 174 | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | - - - - + + + + | mtimestart = lastmillis; for (Entity *e in ents) { if (e.type != MONSTER) continue; Monster *m = [Monster monsterWithType: e.attr2 |
︙ | |||
285 286 287 288 289 290 291 | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | - - - + + + - + - - - - + + - - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + - - - + + + - - + + | self.jumpNext = true; // search for a way around (common) else if (self.trigger < lastmillis && (self.monsterState != M_HOME || !rnd(5))) { // patented "random walk" AI pathfinding (tm) ;) self.targetYaw += 180 + rnd(180); [self transitionWithState: M_SEARCH |
︙ |
Modified src/Variable.h from [780b5706d6] to [237ce5cd40].
1 2 3 4 5 6 7 8 9 10 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 | - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - + + + + + - - - - - + + + + + | #import "Identifier.h" OF_ASSUME_NONNULL_BEGIN #define VARP(name, min_, cur, max_) \ int name = cur; \ \ OF_CONSTRUCTOR() \ { \ enqueueInit(^ { \ |
Modified src/Variable.m from [60a145c003] to [892ebc7d62].
1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | - - - - - + + + + + - - - - - + + + + + - - - - - + + + + + | #import "Variable.h" #include "cube.h" @implementation Variable + (instancetype)variableWithName: (OFString *)name |
︙ |
Modified src/clientextras.m from [d459541c88] to [84515fc725].
1 2 3 4 5 6 7 8 9 10 11 12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - - - - - - + + + + + + + + + | // clientextras.cpp: stuff that didn't fit in client.cpp or clientgame.cpp :) #include "cube.h" #import "Command.h" #import "Monster.h" #import "Player.h" // render players & monsters // very messy ad-hoc handling of animation frames, should be made more // configurable |
︙ |
Modified src/clientgame.m from [0b8b0d202d] to [418707bf92].
︙ | |||
309 310 311 312 313 314 315 | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 | + - + - - - - + - - - + - | // let armour absorb when possible int ad = damage * (player1.armourType + 1) * 20 / 100; if (ad > Player.player1.armour) ad = Player.player1.armour; player1.armour -= ad; damage -= ad; float droll = damage / 0.5f; // give player a kick depending on amount of damage |
︙ |
Modified src/clients.m from [0b6e5b2153] to [895b86000b].
︙ | |||
39 40 41 42 43 44 45 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | - - + + | if (!allow) conoutf(@"editing in multiplayer requires coopedit mode (1)"); return allow; } VARF(rate, 0, 0, 25000, |
︙ | |||
212 213 214 215 216 217 218 | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | - + | msgsizelookup(type)); if (messages.count == 100) { conoutf(@"command flood protection (type %d)", type); return; } OFMutableData *msg = [OFMutableData dataWithItemSize: sizeof(int) |
︙ |
Modified src/clients2c.m from [11f87c82e6] to [9597798812].
︙ | |||
41 42 43 44 45 46 47 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | - + - + - - + - + - - + | Player *player1 = Player.player1; const float r = player1.radius + d.radius; const float dx = player1.origin.x - d.origin.x; const float dy = player1.origin.y - d.origin.y; const float dz = player1.origin.z - d.origin.z; const float rz = player1.aboveEye + d.eyeHeight; const float fx = (float)fabs(dx), fy = (float)fabs(dy), |
︙ | |||
83 84 85 86 87 88 89 | 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 | - + - + | switch (type = getint(&p)) { case SV_INITS2C: // welcome messsage from the server { cn = getint(&p); int prot = getint(&p); if (prot != PROTOCOL_VERSION) { conoutf(@"you are using a different game " |
︙ | |||
261 262 263 264 265 266 267 | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | - - + + | addmsg(1, 2, SV_FRAGS, (Player.player1.frags += frags)); } else { Player *a = getclient(actor); if (a != nil) { if (isteam(a.team, d.name)) conoutf(@"%@ fragged his " |
︙ | |||
299 300 301 302 303 304 305 | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | - - + + + | break; } // server acknowledges that I picked up this item case SV_ITEMACC: realpickup(getint(&p), Player.player1); break; |
︙ | |||
363 364 365 366 367 368 369 | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | - + - | case SV_PING: getint(&p); break; case SV_PONG: addmsg(0, 2, SV_CLIENTPING, Player.player1.ping = (Player.player1.ping * 5 + |
︙ | |||
397 398 399 400 401 402 403 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | - - + + - + | } case SV_SERVMSG: sgetstr(); conoutf(@"%s", text); break; |
Modified src/commands.m from [e072f98aae] to [e486b084f6].
︙ | |||
18 19 20 21 22 23 24 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | - - + + | void alias(OFString *name, OFString *action) { Alias *alias = Identifier.identifiers[name]; if (alias == nil) Identifier.identifiers[name] = [Alias aliasWithName: name |
︙ |
Modified src/console.m from [1d463d8f9f] to [a781a15ab9].
︙ | |||
58 59 60 61 62 63 64 | 58 59 60 61 62 63 64 65 66 67 68 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 | - + - - + + | void conoutf(OFConstantString *format, ...) { va_list arguments; va_start(arguments, format); OFString *string = [[OFString alloc] initWithFormat: format |
︙ | |||
103 104 105 106 107 108 109 | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | - + | static OFMutableArray<KeyMapping *> *keyMappings = nil; COMMAND(keymap, ARG_3STR, ^ (OFString *code, OFString *key, OFString *action) { if (keyMappings == nil) keyMappings = [[OFMutableArray alloc] init]; KeyMapping *mapping = [KeyMapping mappingWithCode: code.cube_intValue |
︙ | |||
181 182 183 184 185 186 187 | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | - - + + | case SDLK_RETURN: break; case SDLK_BACKSPACE: case SDLK_LEFT: if (commandbuf.length > 0) [commandbuf deleteCharactersInRange: |
︙ | |||
217 218 219 220 221 222 223 | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | - + - - + | default: resetcomplete(); } } else { if (code == SDLK_RETURN) { if (commandbuf.length > 0) { if (vhistory == nil) |
︙ |
Modified src/cube.h from [e6d07ee71e] to [966c5f23a3].
︙ | |||
104 105 106 107 108 109 110 | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - - + + | #define SW(w, x, y) SWS(w, x, y, ssize) #define S(x, y) SW(world, x, y) // convenient lookup of a lowest mip cube #define SMALLEST_FACTOR 6 // determines number of mips there can be #define DEFAULT_FACTOR 8 #define LARGEST_FACTOR 11 // 10 is already insane #define SOLID(x) ((x)->type == SOLID) #define MINBORD 2 // 2 cubes from the edge of the world are always solid |
︙ | |||
251 252 253 254 255 256 257 | 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 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | - - - + + + - - - + + + - - + + - - - - - + + + + + - - - - - - + + + + + + | // globals ooh naughty #ifdef __cplusplus extern "C" { #endif // map data, the mips are sequential 2D arrays in memory extern struct sqr *world, *wmip[]; |
︙ |
Modified src/editing.m from [1510ae8332] to [974268cfe4].
︙ | |||
39 40 41 42 43 44 45 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 | - - - - - + + + + + - - - - + + + + - - + + - + + - - + + + + - + - + | } }); } int selh = 0; bool selset = false; |
︙ | |||
123 124 125 126 127 128 129 | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | - - + + - - + + - - + + | noselection() { if (!selset) conoutf(@"no selection"); return !selset; } |
︙ | |||
338 339 340 341 342 343 344 345 | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | + - + - | } makeundo(); copybuf->x = sel.x; copybuf->y = sel.y; blockpaste(copybuf); }) // maintain most recently used of the texture lists when applying texture void |
︙ | |||
404 405 406 407 408 409 410 | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + | COMMAND(editheight, ARG_2INT, ^ (int flr, int amount) { editheight(flr, amount); }) void edittexxy(int type, int t, const struct block *sel) { |
︙ | |||
482 483 484 485 486 487 488 | 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | - - - + + | } static void edittype(int type) { EDITSEL; |
︙ | |||
578 579 580 581 582 583 584 | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 | - + - - - - + + + | sel.xs = MAXARCHVERT; if (sel.ys > MAXARCHVERT) sel.ys = MAXARCHVERT; struct block *sel_ = &sel; // Ugly hack to make the macro work. struct block *sel = sel_; |
︙ |
Modified src/entities.m from [945da2b6da] to [384373114a].
︙ | |||
47 48 49 50 51 52 53 | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 | - - + + - - - + + - - + - - + + - + - - + - - - + - - + - + - - - + + - - - + + + - - + | for (Entity *e in ents) { if (e.type == MAPMODEL) { MapModelInfo *mmi = getmminfo(e.attr2); if (mmi == nil) continue; rendermodel(mmi.name, 0, 1, e.attr4, (float)mmi.rad, |
︙ |
Modified src/physics.m from [95d4c13f64] to [775d6c79ad].
︙ | |||
11 12 13 14 15 16 17 | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | - - + + | #import "MapModelInfo.h" #import "Monster.h" #import "Player.h" #import "Variable.h" // collide with player or monster static bool |
︙ | |||
121 122 123 124 125 126 127 | 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 | - + - - + - - + - - - + + - - - - + + - - - - + + - - + + - - - + + - | float floor = s->floor; switch (s->type) { case SOLID: return false; case CORNER: { int bx = x, by = y, bs = 1; |
︙ | |||
210 211 212 213 214 215 216 | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | - + - - + | // rise thru stair d.origin = OFAddVectors3D( d.origin, OFMakeVector3D(0, 0, rise)); else return false; } else // gravity |
︙ | |||
403 404 405 406 407 408 409 | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | - + - - - - + + + | // mostly if (pl.origin.x < 0 || pl.origin.x >= ssize || pl.origin.y < 0 || pl.origin.y > ssize) pl.outsideMap = true; else { struct sqr *s = S((int)pl.origin.x, (int)pl.origin.y); |
︙ | |||
439 440 441 442 443 444 445 | 428 429 430 431 432 433 434 435 436 437 | - + - - - + | pl.inWater = water; } void moveplayer(DynamicEntity *pl, int moveres, bool local) { for (int i = 0; i < physicsrepeat; i++) |
Modified src/rendercubes.m from [d20e5d1984] to [ee90f3d4f5].
︙ | |||
27 28 29 30 31 32 33 | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | - - - - + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + | setarraypointers(); } // generating the actual vertices is done dynamically every frame and sits at // the leaves of all these functions, and are part of the cpu bottleneck on // really slow machines, hence the macros. |
︙ | |||
71 72 73 74 75 76 77 | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | - - - + + + - - + + | void mipstats(int a, int b, int c) { if (showm) conoutf(@"1x1/2x2/4x4: %d / %d / %d", a, b, c); } |
︙ | |||
134 135 136 137 138 139 140 141 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | + - + - - - - - + + + + - | ol3b = l1->b; ol4r = l2->r; ol4g = l2->g; ol4b = l2->b; } else // continue strip { int lighterr = lighterror * 2; // skip vertices if light values are close enough if ((abs(ol3r - l3->r) < lighterr && |
︙ |
Modified src/renderextras.m from [f1478ac26e] to [8a14c68979].
︙ | |||
202 203 204 205 206 207 208 | 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 | - - - - - - + + + + + - + | particle_splash(2, 2, 40, OFMakeVector3D(e.x, e.y, e.z)); } int e = closestent(); if (e >= 0) { Entity *c = ents[e]; |
︙ |
Modified src/rendergl.m from [8875dffa42] to [e10c3367c9].
︙ | |||
54 55 56 57 58 59 60 | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | - + | char *exts = (char *)glGetString(GL_EXTENSIONS); if (strstr(exts, "GL_EXT_texture_env_combine")) hasoverbright = true; else conoutf(@"WARNING: cannot use overbright lighting, using old " |
︙ | |||
100 101 102 103 104 105 106 | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | - + - | } @try { SDL_Surface *converted = SDL_ConvertSurface(s, format, 0); if (converted == NULL) { conoutf(@"texture cannot be converted " |
︙ | |||
147 148 149 150 151 152 153 | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | - + | IRI.string); // for voodoo cards under linux scaledimg = OFAllocMemory(1, *xs * *ys * 3); gluScaleImage(GL_RGB, s->w, s->h, GL_UNSIGNED_BYTE, s->pixels, *xs, *ys, GL_UNSIGNED_BYTE, scaledimg); } if (gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, *xs, *ys, GL_RGB, |
︙ | |||
198 199 200 201 202 203 204 | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | - + | int num = curtexnum++, frame = aframe.cube_intValue; if (num < 0 || num >= 256 || frame < 0 || frame >= MAXFRAMES) return; mapping[num][frame] = 1; mapname[num][frame] = [name stringByReplacingOccurrencesOfString: @"\\" |
︙ | |||
330 331 332 333 334 335 336 | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | - - + + - + - - + - - + + | VARFP(gamma, 30, 100, 300, { float f = gamma / 100.0f; Uint16 ramp[256]; SDL_CalculateGammaRamp(f, ramp); |
︙ |
Modified src/rendermd2.m from [923fa1d88f] to [11936c1b8d].
︙ | |||
87 88 89 90 91 92 93 | 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 | - + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + | rendermodel(OFString *mdl, int frame, int range, int tex, float rad, OFVector3D position, float yaw, float pitch, bool teammate, float scale, float speed, int snap, int basetime) { MD2 *m = loadmodel(mdl); if (isoccluded(Player.player1.origin.x, Player.player1.origin.y, |
Modified src/renderparticles.m from [f1b52c549a] to [187397123f].
︙ | |||
68 69 70 71 72 73 74 | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | - + - - - - - - - + + + + + + | struct parttype { float r, g, b; int gr, tex; float sz; } parttypes[] = { { 0.7f, 0.6f, 0.3f, 2, 3, 0.06f }, // yellow: sparks { 0.5f, 0.5f, 0.5f, 20, 7, 0.15f }, // grey: small smoke |
︙ |
Modified src/rendertext.m from [656fe9791c] to [af0dd28de8].
︙ | |||
136 137 138 139 140 141 142 | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | - + | void draw_textf(OFConstantString *format, int left, int top, int gl_num, ...) { va_list arguments; va_start(arguments, gl_num); OFString *str = [[OFString alloc] initWithFormat: format |
︙ |
Modified src/rndmap.m from [050a1e4f8d] to [b1dc1f80ec].
︙ | |||
12 13 14 15 16 17 18 | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - - - + + - - + - | ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824.0f; } float smoothednoise(int x, int y, int seed) { |
︙ | |||
74 75 76 77 78 79 80 | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | - - - + + + - - | if (!scale) scale = 10; for (int x = b->x; x <= b->x + b->xs; x++) { for (int y = b->y; y <= b->y + b->ys; y++) { struct sqr *s = S(x, y); if (!SOLID(s) && x != b->x + b->xs && y != b->y + b->ys) s->type = FHF; |
Modified src/savegamedemo.m from [94bda1495e] to [09c2cc3e3c].
︙ | |||
160 161 162 163 164 165 166 | 160 161 162 163 164 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 197 198 199 200 201 202 203 204 205 | - - - + + + - + - + | char mapname[_MAXDEFSTR] = { 0 }; char buf[8]; gzread(f, buf, 8); if (strncmp(buf, "CUBESAVE", 8)) goto out; if (gzgetc(f) != islittleendian) |
︙ | |||
377 378 379 380 381 382 383 | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | - - - - - - - - - - - + + + + + + + + + + + - - - - - + + + + + | setclient(democlientnum, [Player.player1 copy]); readdemotime(); } VAR(demodelaymsec, 0, 120, 500); // spline interpolation |
︙ | |||
449 450 451 452 453 454 455 | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | - - - + + | gzgetv(&dorig); particle_splash(3, ddamage, 1000, dorig); } // FIXME: set more client state here } // insert latest copy of player into history |
︙ |
Modified src/server.m from [95faadaf28] to [043bbacb23].
︙ | |||
395 396 397 398 399 400 401 402 | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | + + - + - - | mapend = lastsec + minremain * 60; interm = 0; } int nonlocalclients = 0; int lastconnect = 0; // main server update, called from cube main loop in sp, or dedicated server // loop void |
︙ | |||
468 469 470 471 472 473 474 | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | - + - - + | case ENET_EVENT_TYPE_CONNECT: { Client *c = addclient(); c.type = ST_TCPIP; c.peer = event.peer; c.peer->data = (void *)(clients.count - 1); char hn[1024]; c.hostname = (enet_address_get_host( |
︙ |
Modified src/sound.m from [78a898d2ad] to [16682ac683].
︙ | |||
53 54 55 56 57 58 59 | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | - + - + | if (nosound) return; stopsound(); if (soundvol && musicvol) { name = [name stringByReplacingOccurrencesOfString: @"\\" |
︙ |
Modified src/tools.h from [754911f423] to [d97579a315].
︙ | |||
14 15 16 17 18 19 20 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | - - - - + + + + | #import <ObjFW/ObjFW.h> #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) #define rnd(max) (rand() % (max)) #define rndreset() (srand(1)) |
︙ |
Modified src/world.m from [a8feb3f63c] to [555501440d].
︙ | |||
157 158 159 160 161 162 163 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | - + - - + - | // crap hack, // needed for // rendering // large mips // next to hfs fh -= o[i]->vdelta / |
︙ | |||
210 211 212 213 214 215 216 | 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 | - + - + - + - - + + - - - + + - - - + + - - - + + - - - + + - | // exactly equal if (o[i]->type != o[3]->type || o[i]->floor != o[3]->floor || o[i]->ceil != o[3]->ceil || o[i]->ftex != o[3]->ftex || o[i]->ctex != o[3]->ctex || abs(o[i + 1]->r - o[0]->r) > |
︙ |
Modified src/worldio.m from [f35a650122] to [3c6f02e0b1].
︙ | |||
166 167 168 169 170 171 172 | 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) { |
︙ | |||
199 200 201 202 203 204 205 | 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; |
︙ | |||
258 259 260 261 262 263 264 265 | 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 |
︙ |
Modified src/worldlight.m from [38a360a277] to [05ada5ded7].
︙ | |||
38 39 40 41 42 43 44 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - + - - + - - | if (hasoverbright) { l /= lightscale; stepl /= lightscale; // coloured light version, special case because most lights are // white if (light.attr3 || light.attr4) { |
︙ | |||
144 145 146 147 148 149 150 | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | - + + + - + - - - - + + + - + | } // median filter, smooths out random noise in light and makes it more mipable void postlightarea(const struct block *a) { // assumes area not on edge of world |
︙ |
Modified src/worldocull.m from [a7de71ad12] to [2e489013a3].
︙ | |||
34 35 36 37 38 39 40 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | - - + + + + | float syaw = (player1.yaw - 90 - af) / 360 * PI2; for (int i = 0; i < NUMRAYS; i++) { float angle = i * PI2 / NUMRAYS; // try to avoid tracing ray if outside of frustrum // apitch must be bigger if fov > 120 if ((apitch > 45 || (angle < byaw && angle > syaw) || |
︙ | |||
121 122 123 124 125 126 127 | 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 164 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 197 198 199 200 201 202 | - + - - + + - - + + - + + - - + + - + - - - + + - + + + - - + + + - + - - - + + - - - + + + - - + + - + + - - + + - + + - + - + - | // find highest and lowest angle in the occlusion map that this cube // spans, based on its most left and right points on the border from the // viewer pov... I see no easier way to do this than this silly code // below float h, l; |
Modified src/worldrender.m from [60ed27f341] to [e1db597b95].
︙ | |||
121 122 123 124 125 126 127 | 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 | - - - + + + - + | render_seg_new( float vx, float vy, float vh, int mip, int x, int y, int xs, int ys) { struct sqr *w = wmip[mip]; int sz = ssize >> mip; int vxx = ((int)vx + (1 << mip) / 2) >> mip; int vyy = ((int)vy + (1 << mip) / 2) >> mip; |
︙ | |||
157 158 159 160 161 162 163 | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | - - - - - - - - - + + + + + + + + + - - - + + + | // loop through the rect 3 times (for floor/ceil/walls seperately, to // facilitate dynamic stripify) for each we skip occluded cubes // (occlusion at higher mip levels is a big time saver!). during the // first loop (ceil) we collect cubes that lie within the lower mip rect // and are also deferred, and render them recursively. Anything left // (perfect mips and higher lods) we render here. |
︙ |