… | |
… | |
155 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
155 | rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE; |
156 | |
156 | |
157 | if (!rect.width) rect.width = 1; |
157 | if (!rect.width) rect.width = 1; |
158 | if (!rect.height) rect.height = 1; |
158 | if (!rect.height) rect.height = 1; |
159 | |
159 | |
160 | rect.width = (rect.width + 3) & ~3; |
|
|
161 | |
|
|
162 | *w = rect.width; |
160 | *w = rect.width; |
163 | *h = rect.height; |
161 | *h = rect.height; |
164 | } |
162 | } |
165 | |
163 | |
166 | typedef uint16_t mapface; |
164 | typedef uint16_t mapface; |
… | |
… | |
171 | float s, t; |
169 | float s, t; |
172 | uint8_t r, g, b, a; |
170 | uint8_t r, g, b, a; |
173 | } maptex; |
171 | } maptex; |
174 | |
172 | |
175 | typedef struct { |
173 | typedef struct { |
176 | int16_t darkness; |
174 | uint16_t darkness; |
177 | mapface face[3]; |
175 | mapface face[3]; |
|
|
176 | uint8_t stat_hp; |
178 | } mapcell; |
177 | } mapcell; |
179 | |
178 | |
180 | typedef struct { |
179 | typedef struct { |
181 | int32_t c0, c1; |
180 | int32_t c0, c1; |
182 | mapcell *col; |
181 | mapcell *col; |
… | |
… | |
310 | if (x >= row->c0) |
309 | if (x >= row->c0) |
311 | { |
310 | { |
312 | if (x >= row->c1) |
311 | if (x >= row->c1) |
313 | break; |
312 | break; |
314 | |
313 | |
315 | row->col[x - row->c0].darkness = -1; |
314 | row->col[x - row->c0].darkness = 0; |
316 | } |
315 | } |
317 | } |
316 | } |
318 | } |
317 | } |
319 | |
318 | |
320 | static void |
319 | static void |
… | |
… | |
1262 | self->y += MAP_EXTEND_Y; |
1261 | self->y += MAP_EXTEND_Y; |
1263 | } |
1262 | } |
1264 | } |
1263 | } |
1265 | |
1264 | |
1266 | void |
1265 | void |
1267 | map1a_update (CFPlus::Map self, SV *data_) |
1266 | map1a_update (CFPlus::Map self, SV *data_, int extmap) |
1268 | CODE: |
1267 | CODE: |
1269 | { |
1268 | { |
1270 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1269 | uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); |
1271 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1270 | uint8_t *data_end = (uint8_t *)SvEND (data_); |
1272 | mapcell *cell; |
1271 | mapcell *cell; |
… | |
… | |
1281 | |
1280 | |
1282 | cell = map_get_cell (self, x, y); |
1281 | cell = map_get_cell (self, x, y); |
1283 | |
1282 | |
1284 | if (flags & 15) |
1283 | if (flags & 15) |
1285 | { |
1284 | { |
1286 | if (cell->darkness < 0) |
1285 | if (!cell->darkness) |
1287 | { |
1286 | { |
1288 | cell->darkness = 0; |
1287 | cell->darkness = 256; |
1289 | cell->face [0] = 0; |
1288 | cell->face [0] = 0; |
1290 | cell->face [1] = 0; |
1289 | cell->face [1] = 0; |
1291 | cell->face [2] = 0; |
1290 | cell->face [2] = 0; |
1292 | } |
1291 | } |
1293 | |
1292 | |
1294 | cell->darkness = flags & 8 ? *data++ : 255; |
|
|
1295 | |
|
|
1296 | //TODO: don't trust server data to be in-range(!) |
1293 | //TODO: don't trust server data to be in-range(!) |
|
|
1294 | |
|
|
1295 | if (flags & 8) |
|
|
1296 | { |
|
|
1297 | if (extmap) |
|
|
1298 | { |
|
|
1299 | uint8_t ext, cmd; |
|
|
1300 | |
|
|
1301 | do |
|
|
1302 | { |
|
|
1303 | ext = *data++; |
|
|
1304 | cmd = ext & 0x7f; |
|
|
1305 | |
|
|
1306 | if (ext < 4) |
|
|
1307 | cell->darkness = 255 - ext * 64 + 1; |
|
|
1308 | else if (ext == 5) // health |
|
|
1309 | cell->stat_hp = *data++; |
|
|
1310 | } |
|
|
1311 | while (cmd & 0x80); |
|
|
1312 | } |
|
|
1313 | else |
|
|
1314 | cell->darkness = *data++ + 1; |
|
|
1315 | } |
1297 | |
1316 | |
1298 | if (flags & 4) |
1317 | if (flags & 4) |
1299 | { |
1318 | { |
1300 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1319 | cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1301 | } |
1320 | } |
… | |
… | |
1309 | { |
1328 | { |
1310 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1329 | cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; |
1311 | } |
1330 | } |
1312 | } |
1331 | } |
1313 | else |
1332 | else |
1314 | cell->darkness = -1; |
1333 | cell->darkness = 0; |
1315 | } |
1334 | } |
1316 | } |
1335 | } |
1317 | |
1336 | |
1318 | SV * |
1337 | SV * |
1319 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
1338 | mapmap (CFPlus::Map self, int x0, int y0, int w, int h) |
… | |
… | |
1535 | for (x = 0; x < sw; x++) |
1554 | for (x = 0; x < sw; x++) |
1536 | if (row->c0 <= x + vx && x + vx < row->c1) |
1555 | if (row->c0 <= x + vx && x + vx < row->c1) |
1537 | { |
1556 | { |
1538 | mapcell *cell = row->col + (x + vx - row->c0); |
1557 | mapcell *cell = row->col + (x + vx - row->c0); |
1539 | |
1558 | |
1540 | darkness[y * sw4 + x] = cell->darkness < 0 |
1559 | darkness[y * sw4 + x] = cell->darkness |
|
|
1560 | ? 255 - cell->darkness + 1 |
1541 | ? 255 - FOW_DARKNESS |
1561 | : 255 - FOW_DARKNESS; |
1542 | : 255 - cell->darkness; |
|
|
1543 | } |
1562 | } |
1544 | } |
1563 | } |
1545 | |
1564 | |
1546 | EXTEND (SP, 3); |
1565 | EXTEND (SP, 3); |
1547 | PUSHs (sv_2mortal (newSViv (sw4))); |
1566 | PUSHs (sv_2mortal (newSViv (sw4))); |
… | |
… | |
1662 | |
1681 | |
1663 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1682 | if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } |
1664 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1683 | if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } |
1665 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1684 | if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } |
1666 | |
1685 | |
1667 | if (cell->darkness <= 0) |
1686 | if (cell->darkness <= 1) |
1668 | { |
1687 | { |
1669 | cell->darkness = -1; |
1688 | cell->darkness = 0; |
1670 | |
1689 | |
1671 | for (z = 0; z <= 2; z++) |
1690 | for (z = 0; z <= 2; z++) |
1672 | { |
1691 | { |
1673 | cell->face[z] = face[z]; |
1692 | cell->face[z] = face[z]; |
1674 | |
1693 | |