Differences From Artifact [85210314d4]:
- File src/editing.m — part of check-in [e8f80b0482] at 2025-03-23 02:03:32 on branch trunk — Convert monster into a class (user: js, size: 13365) [annotate] [blame] [check-ins using]
To Artifact [f776852317]:
- File
src/editing.m
— part of check-in
[6b85eefc85]
at
2025-03-23 02:47:40
on branch trunk
— Remove loop[ijkl]
They confused clang-format a lot. (user: js, size: 13646) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
26 27 28 29 30 31 32 | }; }); } int selh = 0; bool selset = false; | | | | | | | | | > | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | }; }); } int selh = 0; bool selset = false; #define loopselxy(b) \ { \ makeundo(); \ for (int x = 0; x < sel->xs; x++) { \ for (int y = 0; y < sel->ys; y++) { \ struct sqr *s = S(sel->x + x, sel->y + y); \ b; \ } \ } \ remip(sel, 0); \ } int cx, cy, ch; int curedittex[] = { -1, -1, -1 }; bool dragging = false; |
︙ | ︙ | |||
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | static struct block *copybuf = NULL; void copy() { EDITSELMP; if (copybuf) OFFreeMemory(copybuf); copybuf = blockcopy(&sel); } void paste() { EDITMP; | > > | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | static struct block *copybuf = NULL; void copy() { EDITSELMP; if (copybuf) OFFreeMemory(copybuf); copybuf = blockcopy(&sel); } void paste() { EDITMP; |
︙ | ︙ | |||
317 318 319 320 321 322 323 | blockpaste(copybuf); } void tofronttex() // maintain most recently used of the texture lists when applying // texture { | | < | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | blockpaste(copybuf); } void tofronttex() // maintain most recently used of the texture lists when applying // texture { for (int i = 0; i < 3; i++) { int c = curedittex[i]; if (c >= 0) { uchar *p = hdr.texlists[i]; int t = p[c]; for (int a = c - 1; a >= 0; a--) p[a + 1] = p[a]; p[0] = t; |
︙ | ︙ | |||
367 368 369 370 371 372 373 374 375 376 377 378 379 380 | }); } void editheight(int flr, int amount) { EDITSEL; bool isfloor = flr == 0; editheightxy(isfloor, amount, &sel); addmsg(1, 7, SV_EDITH, sel.x, sel.y, sel.xs, sel.ys, isfloor, amount); } COMMAND(editheight, ARG_2INT) void | > | 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | }); } void editheight(int flr, int amount) { EDITSEL; bool isfloor = flr == 0; editheightxy(isfloor, amount, &sel); addmsg(1, 7, SV_EDITH, sel.x, sel.y, sel.xs, sel.ys, isfloor, amount); } COMMAND(editheight, ARG_2INT) void |
︙ | ︙ | |||
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 | }); } void edittex(int type, int dir) { EDITSEL; if (type < 0 || type > 3) return; if (type != lasttype) { tofronttex(); lasttype = type; } int atype = type == 3 ? 1 : type; int i = curedittex[atype]; i = i < 0 ? 0 : i + dir; curedittex[atype] = i = min(max(i, 0), 255); int t = lasttex = hdr.texlists[atype][i]; edittexxy(type, t, &sel); addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t); } void replace() { EDITSELMP; | > > > < | > > | | | | | | | | | | | | | | | | | | | | > > > > | 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 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 | }); } void edittex(int type, int dir) { EDITSEL; if (type < 0 || type > 3) return; if (type != lasttype) { tofronttex(); lasttype = type; } int atype = type == 3 ? 1 : type; int i = curedittex[atype]; i = i < 0 ? 0 : i + dir; curedittex[atype] = i = min(max(i, 0), 255); int t = lasttex = hdr.texlists[atype][i]; edittexxy(type, t, &sel); addmsg(1, 7, SV_EDITT, sel.x, sel.y, sel.xs, sel.ys, type, t); } void replace() { EDITSELMP; for (int x = 0; x < ssize; x++) { for (int y = 0; y < ssize; y++) { struct sqr *s = S(x, y); switch (lasttype) { case 0: if (s->ftex == rtex.ftex) s->ftex = lasttex; break; case 1: if (s->wtex == rtex.wtex) s->wtex = lasttex; break; case 2: if (s->ctex == rtex.ctex) s->ctex = lasttex; break; case 3: if (s->utex == rtex.utex) s->utex = lasttex; break; } } } struct block b = { 0, 0, ssize, ssize }; remip(&b, 0); } void edittypexy(int type, const struct block *sel) { loopselxy(s->type = type); } void edittype(int type) { EDITSEL; if (type == CORNER && (sel.xs != sel.ys || sel.xs == 3 || (sel.xs > 4 && sel.xs != 8) || sel.x & ~-sel.xs || sel.y & ~-sel.ys)) { conoutf(@"corner selection must be power of 2 aligned"); return; } edittypexy(type, &sel); addmsg(1, 6, SV_EDITS, sel.x, sel.y, sel.xs, sel.ys, type); } void heightfield(int t) { |
︙ | ︙ | |||
505 506 507 508 509 510 511 | s->floor = s->ceil - 1; }); } void equalize(int flr) { | | > > > > > | > > > > > > > > > > > > > > | > > | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 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 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | s->floor = s->ceil - 1; }); } void equalize(int flr) { bool isfloor = (flr == 0); EDITSEL; editequalisexy(isfloor, &sel); addmsg(1, 6, SV_EDITE, sel.x, sel.y, sel.xs, sel.ys, isfloor); } COMMAND(equalize, ARG_1INT) void setvdeltaxy(int delta, const struct block *sel) { loopselxy(s->vdelta = max(s->vdelta + delta, 0)); remipmore(sel, 0); } void setvdelta(int delta) { EDITSEL; setvdeltaxy(delta, &sel); addmsg(1, 6, SV_EDITD, sel.x, sel.y, sel.xs, sel.ys, delta); } #define MAXARCHVERT 50 int archverts[MAXARCHVERT][MAXARCHVERT]; bool archvinit = false; void archvertex(int span, int vert, int delta) { if (!archvinit) { archvinit = true; for (int s = 0; s < MAXARCHVERT; s++) for (int v = 0; v < MAXARCHVERT; v++) archverts[s][v] = 0; } if (span >= MAXARCHVERT || vert >= MAXARCHVERT || span < 0 || vert < 0) return; archverts[span][vert] = delta; } void arch(int sidedelta, int _a) { EDITSELMP; sel.xs++; sel.ys++; if (sel.xs > MAXARCHVERT) 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_; loopselxy(s->vdelta = sel->xs > sel->ys ? (archverts[sel->xs - 1][x] + (y == 0 || y == sel->ys - 1 ? sidedelta : 0)) : (archverts[sel->ys - 1][y] + (x == 0 || x == sel->xs - 1 ? sidedelta : 0))); remipmore(sel, 0); } void slope(int xd, int yd) { EDITSELMP; int off = 0; if (xd < 0) off -= xd * sel.xs; if (yd < 0) off -= yd * sel.ys; sel.xs++; sel.ys++; struct block *sel_ = &sel; // Ugly hack to make the macro work. struct block *sel = sel_; loopselxy(s->vdelta = xd * x + yd * y + off); remipmore(sel, 0); } void perlin(int scale, int seed, int psize) { EDITSELMP; sel.xs++; sel.ys++; makeundo(); sel.xs--; sel.ys--; perlinarea(&sel, scale, seed, psize); sel.xs++; sel.ys++; remipmore(&sel, 0); sel.xs--; sel.ys--; } VARF( fullbright, 0, 0, 1, if (fullbright) { if (noteditmode()) return; for (int i = 0; i < mipsize; i++) world[i].r = world[i].g = world[i].b = 176; }); void edittag(int tag) { EDITSELMP; struct block *sel_ = &sel; // Ugly hack to make the macro work. struct block *sel = sel_; loopselxy(s->tag = tag); } void newent(OFString *what, OFString *a1, OFString *a2, OFString *a3, OFString *a4) { EDITSEL; newentity(sel.x, sel.y, (int)player1.origin.z, what, [a1 cube_intValueWithBase:0], [a2 cube_intValueWithBase:0], [a3 cube_intValueWithBase:0], [a4 cube_intValueWithBase:0]); } COMMANDN(select, selectpos, ARG_4INT) COMMAND(edittag, ARG_1INT) |
︙ | ︙ |