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.148 by root, Sat Aug 19 03:57:25 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];
176 uint8_t stat_width, stat_hp; 177 uint8_t stat_width, stat_hp, flags;
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;
1273 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1274 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1274 uint8_t *data_end = (uint8_t *)SvEND (data_); 1275 uint8_t *data_end = (uint8_t *)SvEND (data_);
1275 mapcell *cell; 1276 mapcell *cell;
1276 int x, y, flags; 1277 int x, y, flags;
1277 1278
1278 while (data < data_end) 1279 while (data < data_end - 1)
1279 { 1280 {
1280 flags = (data [0] << 8) + data [1]; data += 2; 1281 flags = (data [0] << 8) + data [1]; data += 2;
1281 1282
1282 x = self->x + ((flags >> 10) & 63); 1283 x = self->x + ((flags >> 10) & 63);
1283 y = self->y + ((flags >> 4) & 63); 1284 y = self->y + ((flags >> 4) & 63);
1314 cell->stat_width = 1; 1315 cell->stat_width = 1;
1315 cell->stat_hp = *data++; 1316 cell->stat_hp = *data++;
1316 } 1317 }
1317 else if (cmd == 6) // monster width 1318 else if (cmd == 6) // monster width
1318 cell->stat_width = *data++ + 1; 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++;
1319 else if (ext & 0x40) // unknown, multibyte => skip 1329 else if (ext & 0x40) // unknown, multibyte => skip
1320 data += *data + 1; 1330 data += *data + 1;
1321 else 1331 else
1322 data++; 1332 data++;
1323 } 1333 }
1457 face = cell->face [z]; 1467 face = cell->face [z];
1458 1468
1459 if (face && face < self->texs) 1469 if (face && face < self->texs)
1460 { 1470 {
1461 maptex tex = self->tex [face]; 1471 maptex tex = self->tex [face];
1462
1463 int px = (x + 1) * 32 - tex.w; 1472 int px = (x + 1) * 32 - tex.w;
1464 int py = (y + 1) * 32 - tex.h; 1473 int py = (y + 1) * 32 - tex.h;
1465 1474
1466 if (last_name != tex.name) 1475 if (last_name != tex.name)
1467 { 1476 {
1468 glEnd (); 1477 glEnd ();
1469 last_name = tex.name;
1470 glBindTexture (GL_TEXTURE_2D, last_name); 1478 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1471 glBegin (GL_QUADS); 1479 glBegin (GL_QUADS);
1472 } 1480 }
1473 1481
1474 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1482 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1475 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1483 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1476 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);
1477 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1485 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1478 } 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 }
1479 } 1506 }
1480 } 1507 }
1481 1508
1482 glEnd (); 1509 glEnd ();
1483 1510
1484 glDisable (GL_TEXTURE_2D); 1511 glDisable (GL_TEXTURE_2D);
1512 glDisable (GL_BLEND);
1485 1513
1486 // top layer: overlays such as the health bar 1514 // top layer: overlays such as the health bar
1487 for (y = 0; y < sh; y++) 1515 for (y = 0; y < sh; y++)
1488 if (0 <= y + vy && y + vy < self->rows) 1516 if (0 <= y + vy && y + vy < self->rows)
1489 { 1517 {
1500 if (cell->stat_hp) 1528 if (cell->stat_hp)
1501 { 1529 {
1502 int width = cell->stat_width * 32; 1530 int width = cell->stat_width * 32;
1503 int thick = sh / 28 + 1 + cell->stat_width; 1531 int thick = sh / 28 + 1 + cell->stat_width;
1504 1532
1505 glColor4ub (0, 0, 0, 127); 1533 glColor3ub (0, 0, 0);
1506 glRectf (px + 1, py, 1534 glRectf (px + 1, py - thick - 2,
1507 px + width - 1, py + thick + 2); 1535 px + width - 1, py);
1508 1536
1509 glColor4ub (cell->stat_hp, 255 - cell->stat_hp, 0, 255); 1537 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
1510 glRectf (px + 2, 1538 glRectf (px + 2,
1511 py + 1, 1539 py - thick - 1,
1512 px + width - 2 - cell->stat_hp * (width - 4) / 255, py + thick + 1); 1540 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1513 } 1541 }
1514 } 1542 }
1515 } 1543 }
1516
1517 glDisable (GL_BLEND);
1518} 1544}
1519 1545
1520void 1546void
1521draw_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)
1522 CODE: 1548 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines