… | |
… | |
1286 | { |
1286 | { |
1287 | cell->darkness = 256; |
1287 | cell->darkness = 256; |
1288 | cell->face [0] = 0; |
1288 | cell->face [0] = 0; |
1289 | cell->face [1] = 0; |
1289 | cell->face [1] = 0; |
1290 | cell->face [2] = 0; |
1290 | cell->face [2] = 0; |
|
|
1291 | cell->stat_hp = 0; |
1291 | } |
1292 | } |
1292 | |
1293 | |
1293 | //TODO: don't trust server data to be in-range(!) |
1294 | //TODO: don't trust server data to be in-range(!) |
1294 | |
1295 | |
1295 | if (flags & 8) |
1296 | if (flags & 8) |
… | |
… | |
1299 | uint8_t ext, cmd; |
1300 | uint8_t ext, cmd; |
1300 | |
1301 | |
1301 | do |
1302 | do |
1302 | { |
1303 | { |
1303 | ext = *data++; |
1304 | ext = *data++; |
1304 | cmd = ext & 0x7f; |
1305 | cmd = ext & 0x3f; |
1305 | |
1306 | |
1306 | if (ext < 4) |
1307 | if (ext < 4) |
1307 | cell->darkness = 255 - ext * 64 + 1; |
1308 | cell->darkness = 255 - ext * 64 + 1; |
1308 | else if (ext == 5) // health |
1309 | else if (ext == 5) // health |
1309 | cell->stat_hp = *data++; |
1310 | cell->stat_hp = *data++; |
|
|
1311 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
1312 | data += *data + 1; |
1310 | } |
1313 | } |
1311 | while (cmd & 0x80); |
1314 | while (cmd & 0x80); |
1312 | } |
1315 | } |
1313 | else |
1316 | else |
1314 | cell->darkness = *data++ + 1; |
1317 | cell->darkness = *data++ + 1; |
… | |
… | |
1438 | { |
1441 | { |
1439 | mapcell *cell = row->col + (x + vx - row->c0); |
1442 | mapcell *cell = row->col + (x + vx - row->c0); |
1440 | |
1443 | |
1441 | face = cell->face [z]; |
1444 | face = cell->face [z]; |
1442 | |
1445 | |
1443 | if (face) |
1446 | if (face && face < self->texs) |
1444 | { |
1447 | { |
1445 | maptex tex = self->tex [face]; |
1448 | maptex tex = self->tex [face]; |
1446 | |
1449 | |
1447 | int px = (x + 1) * 32 - tex.w; |
1450 | int px = (x + 1) * 32 - tex.w; |
1448 | int py = (y + 1) * 32 - tex.h; |
1451 | int py = (y + 1) * 32 - tex.h; |
… | |
… | |
1465 | |
1468 | |
1466 | glEnd (); |
1469 | glEnd (); |
1467 | |
1470 | |
1468 | glDisable (GL_TEXTURE_2D); |
1471 | glDisable (GL_TEXTURE_2D); |
1469 | glDisable (GL_BLEND); |
1472 | glDisable (GL_BLEND); |
|
|
1473 | |
|
|
1474 | // top layer: overlays such as the health bar |
|
|
1475 | for (y = 0; y < sh; y++) |
|
|
1476 | if (0 <= y + vy && y + vy < self->rows) |
|
|
1477 | { |
|
|
1478 | maprow *row = self->row + (y + vy); |
|
|
1479 | |
|
|
1480 | for (x = 0; x < sw; x++) |
|
|
1481 | if (row->c0 <= x + vx && x + vx < row->c1) |
|
|
1482 | { |
|
|
1483 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
1484 | |
|
|
1485 | int px = x * 32; |
|
|
1486 | int py = y * 32; |
|
|
1487 | |
|
|
1488 | if (cell->stat_hp) |
|
|
1489 | { |
|
|
1490 | int width = sh / 28 + 1; |
|
|
1491 | |
|
|
1492 | glColor3ub (0, 0, 0); |
|
|
1493 | glRectf (px + 1, py, px + 31, py + width + 2); |
|
|
1494 | |
|
|
1495 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
|
|
1496 | glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1); |
|
|
1497 | } |
|
|
1498 | } |
|
|
1499 | } |
1470 | } |
1500 | } |
1471 | |
1501 | |
1472 | void |
1502 | void |
1473 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1503 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1474 | CODE: |
1504 | CODE: |
… | |
… | |
1555 | if (row->c0 <= x + vx && x + vx < row->c1) |
1585 | if (row->c0 <= x + vx && x + vx < row->c1) |
1556 | { |
1586 | { |
1557 | mapcell *cell = row->col + (x + vx - row->c0); |
1587 | mapcell *cell = row->col + (x + vx - row->c0); |
1558 | |
1588 | |
1559 | darkness[y * sw4 + x] = cell->darkness |
1589 | darkness[y * sw4 + x] = cell->darkness |
1560 | ? 255 - cell->darkness + 1 |
1590 | ? 255 - (cell->darkness - 1) |
1561 | : 255 - FOW_DARKNESS; |
1591 | : 255 - FOW_DARKNESS; |
1562 | } |
1592 | } |
1563 | } |
1593 | } |
1564 | |
1594 | |
1565 | EXTEND (SP, 3); |
1595 | EXTEND (SP, 3); |
… | |
… | |
1681 | |
1711 | |
1682 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1712 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1683 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1713 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1684 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1714 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1685 | |
1715 | |
1686 | if (cell->darkness <= 1) |
1716 | if (cell->darkness == 0) |
1687 | { |
1717 | { |
1688 | cell->darkness = 0; |
1718 | cell->darkness = 0; |
1689 | |
1719 | |
1690 | for (z = 0; z <= 2; z++) |
1720 | for (z = 0; z <= 2; z++) |
1691 | { |
1721 | { |