… | |
… | |
294 | static void |
294 | static void |
295 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
295 | map_blank (CFPlus__Map self, int x0, int y0, int w, int h) |
296 | { |
296 | { |
297 | int x, y; |
297 | int x, y; |
298 | maprow *row; |
298 | maprow *row; |
|
|
299 | mapcell *cell; |
299 | |
300 | |
300 | for (y = y0; y < y0 + h; y++) |
301 | for (y = y0; y < y0 + h; y++) |
301 | if (y >= 0) |
302 | if (y >= 0) |
302 | { |
303 | { |
303 | if (y >= self->rows) |
304 | if (y >= self->rows) |
… | |
… | |
309 | if (x >= row->c0) |
310 | if (x >= row->c0) |
310 | { |
311 | { |
311 | if (x >= row->c1) |
312 | if (x >= row->c1) |
312 | break; |
313 | break; |
313 | |
314 | |
314 | row->col[x - row->c0].darkness = 0; |
315 | cell = row->col + x - row->c0; |
|
|
316 | |
|
|
317 | cell->darkness = 0; |
|
|
318 | cell->stat_hp = 0; |
315 | } |
319 | } |
316 | } |
320 | } |
317 | } |
321 | } |
318 | |
322 | |
319 | static void |
323 | static void |
… | |
… | |
1299 | uint8_t ext, cmd; |
1303 | uint8_t ext, cmd; |
1300 | |
1304 | |
1301 | do |
1305 | do |
1302 | { |
1306 | { |
1303 | ext = *data++; |
1307 | ext = *data++; |
1304 | cmd = ext & 0x7f; |
1308 | cmd = ext & 0x3f; |
1305 | |
1309 | |
1306 | if (ext < 4) |
1310 | if (ext < 4) |
1307 | cell->darkness = 255 - ext * 64 + 1; |
1311 | cell->darkness = 255 - ext * 64 + 1; |
1308 | else if (ext == 5) // health |
1312 | else if (ext == 5) // health |
1309 | cell->stat_hp = *data++; |
1313 | cell->stat_hp = *data++; |
|
|
1314 | else if (ext & 0x40) // unknown, multibyte => skip |
|
|
1315 | data += *data + 1; |
1310 | } |
1316 | } |
1311 | while (cmd & 0x80); |
1317 | while (cmd & 0x80); |
1312 | } |
1318 | } |
1313 | else |
1319 | else |
1314 | cell->darkness = *data++ + 1; |
1320 | cell->darkness = *data++ + 1; |
… | |
… | |
1328 | { |
1334 | { |
1329 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1335 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1330 | } |
1336 | } |
1331 | } |
1337 | } |
1332 | else |
1338 | else |
|
|
1339 | { |
1333 | cell->darkness = 0; |
1340 | cell->darkness = 0; |
|
|
1341 | cell->stat_hp = 0; |
|
|
1342 | } |
1334 | } |
1343 | } |
1335 | } |
1344 | } |
1336 | |
1345 | |
1337 | SV * |
1346 | SV * |
1338 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1347 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
… | |
… | |
1438 | { |
1447 | { |
1439 | mapcell *cell = row->col + (x + vx - row->c0); |
1448 | mapcell *cell = row->col + (x + vx - row->c0); |
1440 | |
1449 | |
1441 | face = cell->face [z]; |
1450 | face = cell->face [z]; |
1442 | |
1451 | |
1443 | if (face) |
1452 | if (face && face < self->texs) |
1444 | { |
1453 | { |
1445 | maptex tex = self->tex [face]; |
1454 | maptex tex = self->tex [face]; |
1446 | |
1455 | |
1447 | int px = (x + 1) * 32 - tex.w; |
1456 | int px = (x + 1) * 32 - tex.w; |
1448 | int py = (y + 1) * 32 - tex.h; |
1457 | int py = (y + 1) * 32 - tex.h; |
… | |
… | |
1465 | |
1474 | |
1466 | glEnd (); |
1475 | glEnd (); |
1467 | |
1476 | |
1468 | glDisable (GL_TEXTURE_2D); |
1477 | glDisable (GL_TEXTURE_2D); |
1469 | glDisable (GL_BLEND); |
1478 | glDisable (GL_BLEND); |
|
|
1479 | |
|
|
1480 | // top layer: overlays such as the health bar |
|
|
1481 | for (y = 0; y < sh; y++) |
|
|
1482 | if (0 <= y + vy && y + vy < self->rows) |
|
|
1483 | { |
|
|
1484 | maprow *row = self->row + (y + vy); |
|
|
1485 | |
|
|
1486 | for (x = 0; x < sw; x++) |
|
|
1487 | if (row->c0 <= x + vx && x + vx < row->c1) |
|
|
1488 | { |
|
|
1489 | mapcell *cell = row->col + (x + vx - row->c0); |
|
|
1490 | |
|
|
1491 | int px = x * 32; |
|
|
1492 | int py = y * 32; |
|
|
1493 | |
|
|
1494 | if (cell->stat_hp) |
|
|
1495 | { |
|
|
1496 | int width = sh / 28 + 1; |
|
|
1497 | |
|
|
1498 | glColor3ub (0, 0, 0); |
|
|
1499 | glRectf (px + 1, py, px + 31, py + width + 2); |
|
|
1500 | |
|
|
1501 | glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); |
|
|
1502 | glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1); |
|
|
1503 | } |
|
|
1504 | } |
|
|
1505 | } |
1470 | } |
1506 | } |
1471 | |
1507 | |
1472 | void |
1508 | void |
1473 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1509 | draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) |
1474 | CODE: |
1510 | CODE: |
… | |
… | |
1555 | if (row->c0 <= x + vx && x + vx < row->c1) |
1591 | if (row->c0 <= x + vx && x + vx < row->c1) |
1556 | { |
1592 | { |
1557 | mapcell *cell = row->col + (x + vx - row->c0); |
1593 | mapcell *cell = row->col + (x + vx - row->c0); |
1558 | |
1594 | |
1559 | darkness[y * sw4 + x] = cell->darkness |
1595 | darkness[y * sw4 + x] = cell->darkness |
1560 | ? 255 - cell->darkness + 1 |
1596 | ? 255 - (cell->darkness - 1) |
1561 | : 255 - FOW_DARKNESS; |
1597 | : 255 - FOW_DARKNESS; |
1562 | } |
1598 | } |
1563 | } |
1599 | } |
1564 | |
1600 | |
1565 | EXTEND (SP, 3); |
1601 | EXTEND (SP, 3); |
… | |
… | |
1681 | |
1717 | |
1682 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1718 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1683 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1719 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1684 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1720 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1685 | |
1721 | |
1686 | if (cell->darkness <= 1) |
1722 | if (cell->darkness == 0) |
1687 | { |
1723 | { |
1688 | cell->darkness = 0; |
1724 | cell->darkness = 0; |
1689 | |
1725 | |
1690 | for (z = 0; z <= 2; z++) |
1726 | for (z = 0; z <= 2; z++) |
1691 | { |
1727 | { |