ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.142 by root, Fri Aug 18 01:27:15 2006 UTC vs.
Revision 1.153 by root, Tue Sep 19 22:02:38 2006 UTC

169 float s, t; 169 float s, t;
170 uint8_t r, g, b, a; 170 uint8_t r, g, b, a;
171} maptex; 171} maptex;
172 172
173typedef struct { 173typedef struct {
174 uint32_t player;
175 mapface face[3];
174 uint16_t darkness; 176 uint16_t darkness;
175 mapface face[3]; 177 uint8_t stat_width, stat_hp, flags;
176 uint8_t stat_hp;
177} mapcell; 178} mapcell;
178 179
179typedef struct { 180typedef struct {
180 int32_t c0, c1; 181 int32_t c0, c1;
181 mapcell *col; 182 mapcell *col;
294static void 295static void
295map_blank (CFPlus__Map self, int x0, int y0, int w, int h) 296map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
296{ 297{
297 int x, y; 298 int x, y;
298 maprow *row; 299 maprow *row;
300 mapcell *cell;
299 301
300 for (y = y0; y < y0 + h; y++) 302 for (y = y0; y < y0 + h; y++)
301 if (y >= 0) 303 if (y >= 0)
302 { 304 {
303 if (y >= self->rows) 305 if (y >= self->rows)
309 if (x >= row->c0) 311 if (x >= row->c0)
310 { 312 {
311 if (x >= row->c1) 313 if (x >= row->c1)
312 break; 314 break;
313 315
314 row->col[x - row->c0].darkness = 0; 316 cell = row->col + x - row->c0;
317
318 cell->darkness = 0;
319 cell->stat_hp = 0;
315 } 320 }
316 } 321 }
317} 322}
318 323
319static void 324static void
1269 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1274 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1270 uint8_t *data_end = (uint8_t *)SvEND (data_); 1275 uint8_t *data_end = (uint8_t *)SvEND (data_);
1271 mapcell *cell; 1276 mapcell *cell;
1272 int x, y, flags; 1277 int x, y, flags;
1273 1278
1274 while (data < data_end) 1279 while (data < data_end - 1)
1275 { 1280 {
1276 flags = (data [0] << 8) + data [1]; data += 2; 1281 flags = (data [0] << 8) + data [1]; data += 2;
1277 1282
1278 x = self->x + ((flags >> 10) & 63); 1283 x = self->x + ((flags >> 10) & 63);
1279 y = self->y + ((flags >> 4) & 63); 1284 y = self->y + ((flags >> 4) & 63);
1299 uint8_t ext, cmd; 1304 uint8_t ext, cmd;
1300 1305
1301 do 1306 do
1302 { 1307 {
1303 ext = *data++; 1308 ext = *data++;
1304 cmd = ext & 0x7f; 1309 cmd = ext & 0x3f;
1305 1310
1306 if (ext < 4) 1311 if (cmd < 4)
1307 cell->darkness = 255 - ext * 64 + 1; 1312 cell->darkness = 255 - ext * 64 + 1;
1308 else if (ext == 5) // health 1313 else if (cmd == 5) // health
1314 {
1315 cell->stat_width = 1;
1309 cell->stat_hp = *data++; 1316 cell->stat_hp = *data++;
1317 }
1318 else if (cmd == 6) // monster width
1319 cell->stat_width = *data++ + 1;
1320 else if (cmd == 0x47) // monster width
1321 {
1322 if (*data == 4)
1323 ; // decode player tag
1324
1325 data += *data + 1;
1326 }
1327 else if (cmd == 8) // cell flags
1328 cell->flags = *data++;
1329 else if (ext & 0x40) // unknown, multibyte => skip
1330 data += *data + 1;
1331 else
1332 data++;
1310 } 1333 }
1311 while (cmd & 0x80); 1334 while (ext & 0x80);
1312 } 1335 }
1313 else 1336 else
1314 cell->darkness = *data++ + 1; 1337 cell->darkness = *data++ + 1;
1315 } 1338 }
1316 1339
1328 { 1351 {
1329 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1352 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1330 } 1353 }
1331 } 1354 }
1332 else 1355 else
1356 {
1333 cell->darkness = 0; 1357 cell->darkness = 0;
1358 cell->stat_hp = 0;
1359 }
1334 } 1360 }
1335} 1361}
1336 1362
1337SV * 1363SV *
1338mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1364mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1438 { 1464 {
1439 mapcell *cell = row->col + (x + vx - row->c0); 1465 mapcell *cell = row->col + (x + vx - row->c0);
1440 1466
1441 face = cell->face [z]; 1467 face = cell->face [z];
1442 1468
1443 if (face) 1469 if (face && face < self->texs)
1444 { 1470 {
1445 maptex tex = self->tex [face]; 1471 maptex tex = self->tex [face];
1446
1447 int px = (x + 1) * 32 - tex.w; 1472 int px = (x + 1) * 32 - tex.w;
1448 int py = (y + 1) * 32 - tex.h; 1473 int py = (y + 1) * 32 - tex.h;
1449 1474
1450 if (last_name != tex.name) 1475 if (last_name != tex.name)
1451 { 1476 {
1452 glEnd (); 1477 glEnd ();
1453 last_name = tex.name;
1454 glBindTexture (GL_TEXTURE_2D, last_name); 1478 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1455 glBegin (GL_QUADS); 1479 glBegin (GL_QUADS);
1456 } 1480 }
1457 1481
1458 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1482 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1459 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1483 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1460 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); 1484 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1461 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1485 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1462 } 1486 }
1487
1488 if (cell->flags && z == 2)
1489 {
1490 if (cell->flags & 1)
1491 {
1492 maptex tex = self->tex [1];
1493 int px = (x + 1) * 32 - tex.w + 2;
1494 int py = (y + 1) * 32 - tex.h - 6;
1495
1496 glEnd ();
1497 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1498 glBegin (GL_QUADS);
1499
1500 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1501 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1502 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1503 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1504 }
1505 }
1463 } 1506 }
1464 } 1507 }
1465 1508
1466 glEnd (); 1509 glEnd ();
1467 1510
1468 glDisable (GL_TEXTURE_2D); 1511 glDisable (GL_TEXTURE_2D);
1469 glDisable (GL_BLEND); 1512 glDisable (GL_BLEND);
1513
1514 // top layer: overlays such as the health bar
1515 for (y = 0; y < sh; y++)
1516 if (0 <= y + vy && y + vy < self->rows)
1517 {
1518 maprow *row = self->row + (y + vy);
1519
1520 for (x = 0; x < sw; x++)
1521 if (row->c0 <= x + vx && x + vx < row->c1)
1522 {
1523 mapcell *cell = row->col + (x + vx - row->c0);
1524
1525 int px = x * 32;
1526 int py = y * 32;
1527
1528 if (cell->stat_hp)
1529 {
1530 int width = cell->stat_width * 32;
1531 int thick = sh / 28 + 1 + cell->stat_width;
1532
1533 glColor3ub (0, 0, 0);
1534 glRectf (px + 1, py - thick - 2,
1535 px + width - 1, py);
1536
1537 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
1538 glRectf (px + 2,
1539 py - thick - 1,
1540 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1541 }
1542 }
1543 }
1470} 1544}
1471 1545
1472void 1546void
1473draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1547draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1474 CODE: 1548 CODE:
1555 if (row->c0 <= x + vx && x + vx < row->c1) 1629 if (row->c0 <= x + vx && x + vx < row->c1)
1556 { 1630 {
1557 mapcell *cell = row->col + (x + vx - row->c0); 1631 mapcell *cell = row->col + (x + vx - row->c0);
1558 1632
1559 darkness[y * sw4 + x] = cell->darkness 1633 darkness[y * sw4 + x] = cell->darkness
1560 ? 255 - cell->darkness + 1 1634 ? 255 - (cell->darkness - 1)
1561 : 255 - FOW_DARKNESS; 1635 : 255 - FOW_DARKNESS;
1562 } 1636 }
1563 } 1637 }
1564 1638
1565 EXTEND (SP, 3); 1639 EXTEND (SP, 3);
1681 1755
1682 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1756 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1683 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1757 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1684 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1758 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1685 1759
1686 if (cell->darkness <= 1) 1760 if (cell->darkness == 0)
1687 { 1761 {
1688 cell->darkness = 0; 1762 cell->darkness = 0;
1689 1763
1690 for (z = 0; z <= 2; z++) 1764 for (z = 0; z <= 2; z++)
1691 { 1765 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines