… | |
… | |
578 | tex->g = g; |
578 | tex->g = g; |
579 | tex->b = b; |
579 | tex->b = b; |
580 | tex->a = a; |
580 | tex->a = a; |
581 | } |
581 | } |
582 | |
582 | |
583 | void |
|
|
584 | scroll (CFClient::Map self, int dx, int dy) |
|
|
585 | CODE: |
|
|
586 | { |
|
|
587 | if (dx > 0) |
|
|
588 | map_blank (self, self->x, self->y, dx - 1, self->h); |
|
|
589 | else if (dx < 0) |
|
|
590 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
|
|
591 | |
|
|
592 | if (dy > 0) |
|
|
593 | map_blank (self, self->x, self->y, self->w, dy - 1); |
|
|
594 | else if (dy < 0) |
|
|
595 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
|
|
596 | |
|
|
597 | self->x += dx; self->ox += dx; |
|
|
598 | self->y += dy; self->oy += dy; |
|
|
599 | |
|
|
600 | while (self->y < 0) |
|
|
601 | { |
|
|
602 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
603 | |
|
|
604 | self->rows += MAP_EXTEND_Y; |
|
|
605 | self->y += MAP_EXTEND_Y; |
|
|
606 | } |
|
|
607 | } |
|
|
608 | |
|
|
609 | int |
583 | int |
610 | ox (CFClient::Map self) |
584 | ox (CFClient::Map self) |
611 | ALIAS: |
585 | ALIAS: |
612 | oy = 1 |
586 | oy = 1 |
613 | CODE: |
587 | CODE: |
… | |
… | |
618 | } |
592 | } |
619 | OUTPUT: |
593 | OUTPUT: |
620 | RETVAL |
594 | RETVAL |
621 | |
595 | |
622 | void |
596 | void |
|
|
597 | scroll (CFClient::Map self, int dx, int dy) |
|
|
598 | CODE: |
|
|
599 | { |
|
|
600 | if (dx > 0) |
|
|
601 | map_blank (self, self->x, self->y, dx - 1, self->h); |
|
|
602 | else if (dx < 0) |
|
|
603 | map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); |
|
|
604 | |
|
|
605 | if (dy > 0) |
|
|
606 | map_blank (self, self->x, self->y, self->w, dy - 1); |
|
|
607 | else if (dy < 0) |
|
|
608 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); |
|
|
609 | |
|
|
610 | self->ox += dx; self->x += dx; |
|
|
611 | self->oy += dy; self->y += dy; |
|
|
612 | |
|
|
613 | while (self->y < 0) |
|
|
614 | { |
|
|
615 | Prepend (maprow, self->row, self->rows, MAP_EXTEND_Y); |
|
|
616 | |
|
|
617 | self->rows += MAP_EXTEND_Y; |
|
|
618 | self->y += MAP_EXTEND_Y; |
|
|
619 | } |
|
|
620 | } |
|
|
621 | |
|
|
622 | void |
623 | map1a_update (CFClient::Map self, SV *data_) |
623 | map1a_update (CFClient::Map self, SV *data_) |
624 | CODE: |
624 | CODE: |
625 | { |
625 | { |
626 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
626 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
627 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
627 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
628 | |
628 | |
629 | while (data < data_end) |
629 | while (data < data_end) |
630 | { |
630 | { |
631 | int flags = (data [0] << 8) + data [1]; data += 2; |
631 | int flags = (data [0] << 8) + data [1]; data += 2; |
632 | |
632 | |
633 | int x = ((flags >> 10) & 63) + self->x; |
633 | int x = ((flags >> 10) & 63) + self->x; |
… | |
… | |
635 | |
635 | |
636 | mapcell *cell = map_get_cell (self, x, y); |
636 | mapcell *cell = map_get_cell (self, x, y); |
637 | |
637 | |
638 | if (flags & 15) |
638 | if (flags & 15) |
639 | { |
639 | { |
640 | if (cell->darkness < 0) // && x < self->w && y < self->h) |
640 | if (cell->darkness < 0) |
641 | { |
641 | { |
642 | cell->darkness = 0; |
642 | cell->darkness = 0; |
643 | cell->face [0] = 0; |
643 | cell->face [0] = 0; |
644 | cell->face [1] = 0; |
644 | cell->face [1] = 0; |
645 | cell->face [2] = 0; |
645 | cell->face [2] = 0; |
646 | } |
646 | } |
647 | |
647 | |
648 | cell->darkness = flags & 8 ? *data++ : 255; |
648 | cell->darkness = flags & 8 ? *data++ : 255; |
649 | |
649 | |
650 | //TODO: don't trust server data to be in-range(!) |
650 | //TODO: don't trust server data to be in-range(!) |
651 | |
651 | |
652 | if (flags & 4) |
652 | if (flags & 4) |