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

Function restoreeditundo

source/src/editing.cpp:526–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524extern int worldiodebug;
525
526void restoreeditundo(ucharbuf &q)
527{
528 int type, len, explen;
529 while(!q.overread() && (type = getuint(q)))
530 {
531 int bx = getuint(q), by = getuint(q), bxs = getuint(q), bys = getuint(q);
532 short pp[5];
533 loopi(5) pp[i] = getint(q);
534 len = getuint(q);
535 if((bx | by | (bx + bxs) | (by + bys)) & ~(ssize - 1)) continue;
536 explen = bxs * bys;
537 block *b = (block *)new uchar[sizeof(block) + explen * sizeof(sqr)];
538 b->x = bx; b->y = by; b->xs = bxs; b->ys = bys;
539 loopi(5) b->p[i] = pp[i];
540 ucharbuf p = q.subbuf(len);
541 rldecodecubes(p, (sqr *)(b+1), explen, 6, true);
542 switch(type)
543 {
544 case 10: undos.insert(0, b); break;
545 case 20: redos.insert(0, b); break;
546 default: freeblock(b); break;
547 }
548 #ifdef _DEBUG
549 if(worldiodebug) switch(type)
550 {
551 case 10:
552 case 20:
553 clientlogf(" got %sdo x %d, y %d, xs %d, ys %d, remaining %d, overread %d", type == 10 ? "un" : "re", b->x, b->y, b->xs, b->ys, q.remaining(), int(q.overread()));
554 break;
555 }
556 #endif
557 }
558 if(undos.length() || redos.length()) conoutf("restored editing history: %d undos and %d redos", undos.length(), redos.length());
559}
560
561int rlencodeundo(int type, vector<uchar> &t, block *s)
562{

Callers 1

loopvFunction · 0.85

Calls 12

getuintFunction · 0.85
getintFunction · 0.85
rldecodecubesFunction · 0.85
freeblockFunction · 0.85
clientlogfFunction · 0.85
overreadMethod · 0.80
loopiFunction · 0.70
conoutfFunction · 0.70
subbufMethod · 0.45
insertMethod · 0.45
remainingMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected