MCPcopy Create free account
hub / github.com/assaultcube/AC / paste

Function paste

source/src/editing.cpp:637–679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635COMMAND(copy, "");
636
637void paste()
638{
639 EDITSEL("paste");
640 bool mp = multiplayer(NULL);
641 if(mp)
642 {
643 loopv(copybuffers) if(copybuffers[i]->xs * copybuffers[i]->ys > MAXNETBLOCKSQR)
644 {
645 conoutf("\f3copied area too big for multiplayer pasting");
646 return;
647 }
648 }
649 if(!copybuffers.length()) { conoutf("nothing to paste"); return; }
650
651 uchar usedslots[256] = { 0 }, *texmap = NULL;
652 if(!mp)
653 {
654 loopv(copybuffers) blocktexusage(*copybuffers[i], usedslots);
655 if(sels.length() && copytexconfig) texmap = texconfig_paste(copytexconfig, usedslots);
656 }
657
658 loopv(sels)
659 {
660 block sel = sels[i];
661 int selx = sel.x;
662 int sely = sel.y;
663
664 loopvj(copybuffers)
665 {
666 block *copyblock = copybuffers[j];
667 int dx = copyblock->x - copybuffers[0]->x, dy = copyblock->y - copybuffers[0]->y;
668
669 sel.xs = copyblock->xs;
670 sel.ys = copyblock->ys;
671 sel.x = selx + dx;
672 sel.y = sely + dy;
673 if(!correctsel(sel) || sel.xs!=copyblock->xs || sel.ys!=copyblock->ys) { conoutf("incorrect selection"); return; }
674 makeundo(sel);
675 blockpaste(*copyblock, sel.x, sel.y, true, texmap);
676 if(mp) netblockpaste(*copyblock, sel.x, sel.y, true);
677 }
678 }
679}
680COMMAND(paste, "");
681
682void tofronttex() // maintain most recently used of the texture lists when applying texture

Callers

nothing calls this directly

Calls 6

multiplayerFunction · 0.85
blocktexusageFunction · 0.85
texconfig_pasteFunction · 0.85
loopvFunction · 0.70
conoutfFunction · 0.70
lengthMethod · 0.45

Tested by

no test coverage detected