… | |
… | |
150 | if (x >= row->c0) |
150 | if (x >= row->c0) |
151 | { |
151 | { |
152 | if (x >= row->c1) |
152 | if (x >= row->c1) |
153 | break; |
153 | break; |
154 | |
154 | |
155 | mapcell *cell = row->col + (x - row->c0); |
155 | row->col[x - row->c0].darkness = -1; |
156 | cell->darkness = -1; |
|
|
157 | cell->face [2] = 0; |
|
|
158 | } |
156 | } |
159 | } |
157 | } |
160 | } |
158 | } |
161 | |
159 | |
162 | MODULE = CFClient PACKAGE = CFClient |
160 | MODULE = CFClient PACKAGE = CFClient |
… | |
… | |
560 | { |
558 | { |
561 | cell->face [2] = (data [0] << 8) + data [1]; data += 2; |
559 | cell->face [2] = (data [0] << 8) + data [1]; data += 2; |
562 | } |
560 | } |
563 | } |
561 | } |
564 | else |
562 | else |
565 | { |
|
|
566 | cell->darkness = -1; |
563 | cell->darkness = -1; |
567 | cell->face [2] = 0; |
|
|
568 | } |
|
|
569 | } |
564 | } |
570 | } |
565 | } |
571 | |
566 | |
572 | void |
567 | void |
573 | draw (CFClient::Map self, int x0, int y0, int sw, int sh) |
568 | draw (CFClient::Map self, int x0, int y0, int sw, int sh) |
574 | CODE: |
569 | PPCODE: |
575 | { |
570 | { |
|
|
571 | int sw4 = (sw + 3) & ~3; |
|
|
572 | SV *darkness_sv = sv_2mortal (newSV (sw4 * sh)); |
|
|
573 | uint8_t *darkness = SvPVX (darkness_sv); |
|
|
574 | |
|
|
575 | SvPOK_only (darkness_sv); |
|
|
576 | SvCUR_set (darkness_sv, sw4 * sh); |
|
|
577 | |
576 | int vx = self->vx = self->w >= sw |
578 | int vx = self->vx = self->w >= sw |
577 | ? self->x + (self->w - sw) / 2 |
579 | ? self->x + (self->w - sw) / 2 |
578 | : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); |
580 | : MIN (self->x, MAX (self->x + self->w - sw + 1, self->vx)); |
579 | |
581 | |
580 | int vy = self->vy = self->h >= sh |
582 | int vy = self->vy = self->h >= sh |
… | |
… | |
602 | |
604 | |
603 | for (x = 0; x < sw; x++) |
605 | for (x = 0; x < sw; x++) |
604 | if (row->c0 <= x + vx && x + vx < row->c1) |
606 | if (row->c0 <= x + vx && x + vx < row->c1) |
605 | { |
607 | { |
606 | mapcell *cell = row->col + (x + vx - row->c0); |
608 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
609 | |
|
|
610 | darkness[y * sw4 + x] = cell->darkness < 0 |
|
|
611 | ? 255 - FOW_DARKNESS |
|
|
612 | : 255 - cell->darkness; |
|
|
613 | |
607 | uint16_t face = cell->face [z]; |
614 | uint16_t face = cell->face [z]; |
608 | |
615 | |
609 | if (face) |
616 | if (face) |
610 | { |
617 | { |
611 | mapface tex = self->face [face]; |
618 | mapface tex = self->face [face]; |
… | |
… | |
628 | } |
635 | } |
629 | } |
636 | } |
630 | } |
637 | } |
631 | |
638 | |
632 | glEnd (); |
639 | glEnd (); |
633 | } |
|
|
634 | |
640 | |
|
|
641 | glDisable (GL_TEXTURE_2D); |
|
|
642 | glDisable (GL_BLEND); |
|
|
643 | |
|
|
644 | EXTEND (SP, 3); |
|
|
645 | PUSHs (sv_2mortal (newSViv (sw4))); |
|
|
646 | PUSHs (sv_2mortal (newSViv (sh))); |
|
|
647 | PUSHs (darkness_sv); |
|
|
648 | } |
|
|
649 | |