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.140 by root, Mon Aug 14 03:41:25 2006 UTC vs.
Revision 1.143 by root, Fri Aug 18 02:23:39 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 int16_t darkness; 174 uint16_t darkness;
175 mapface face[3]; 175 mapface face[3];
176 uint8_t stat_hp;
176} mapcell; 177} mapcell;
177 178
178typedef struct { 179typedef struct {
179 int32_t c0, c1; 180 int32_t c0, c1;
180 mapcell *col; 181 mapcell *col;
308 if (x >= row->c0) 309 if (x >= row->c0)
309 { 310 {
310 if (x >= row->c1) 311 if (x >= row->c1)
311 break; 312 break;
312 313
313 row->col[x - row->c0].darkness = -1; 314 row->col[x - row->c0].darkness = 0;
314 } 315 }
315 } 316 }
316} 317}
317 318
318static void 319static void
1260 self->y += MAP_EXTEND_Y; 1261 self->y += MAP_EXTEND_Y;
1261 } 1262 }
1262} 1263}
1263 1264
1264void 1265void
1265map1a_update (CFPlus::Map self, SV *data_) 1266map1a_update (CFPlus::Map self, SV *data_, int extmap)
1266 CODE: 1267 CODE:
1267{ 1268{
1268 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1269 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1269 uint8_t *data_end = (uint8_t *)SvEND (data_); 1270 uint8_t *data_end = (uint8_t *)SvEND (data_);
1270 mapcell *cell; 1271 mapcell *cell;
1279 1280
1280 cell = map_get_cell (self, x, y); 1281 cell = map_get_cell (self, x, y);
1281 1282
1282 if (flags & 15) 1283 if (flags & 15)
1283 { 1284 {
1284 if (cell->darkness < 0) 1285 if (!cell->darkness)
1285 { 1286 {
1286 cell->darkness = 0; 1287 cell->darkness = 256;
1287 cell->face [0] = 0; 1288 cell->face [0] = 0;
1288 cell->face [1] = 0; 1289 cell->face [1] = 0;
1289 cell->face [2] = 0; 1290 cell->face [2] = 0;
1291 cell->stat_hp = 0;
1290 } 1292 }
1291 1293
1292 cell->darkness = flags & 8 ? *data++ : 255;
1293
1294 //TODO: don't trust server data to be in-range(!) 1294 //TODO: don't trust server data to be in-range(!)
1295
1296 if (flags & 8)
1297 {
1298 if (extmap)
1299 {
1300 uint8_t ext, cmd;
1301
1302 do
1303 {
1304 ext = *data++;
1305 cmd = ext & 0x7f;
1306
1307 if (ext < 4)
1308 cell->darkness = 255 - ext * 64 + 1;
1309 else if (ext == 5) // health
1310 cell->stat_hp = *data++;
1311 }
1312 while (cmd & 0x80);
1313 }
1314 else
1315 cell->darkness = *data++ + 1;
1316 }
1295 1317
1296 if (flags & 4) 1318 if (flags & 4)
1297 { 1319 {
1298 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1320 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1299 } 1321 }
1307 { 1329 {
1308 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1330 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1309 } 1331 }
1310 } 1332 }
1311 else 1333 else
1312 cell->darkness = -1; 1334 cell->darkness = 0;
1313 } 1335 }
1314} 1336}
1315 1337
1316SV * 1338SV *
1317mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1339mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1444 1466
1445 glEnd (); 1467 glEnd ();
1446 1468
1447 glDisable (GL_TEXTURE_2D); 1469 glDisable (GL_TEXTURE_2D);
1448 glDisable (GL_BLEND); 1470 glDisable (GL_BLEND);
1471
1472 for (y = 0; y < sh; y++)
1473 if (0 <= y + vy && y + vy < self->rows)
1474 {
1475 maprow *row = self->row + (y + vy);
1476
1477 for (x = 0; x < sw; x++)
1478 if (row->c0 <= x + vx && x + vx < row->c1)
1479 {
1480 mapcell *cell = row->col + (x + vx - row->c0);
1481
1482 int px = x * 32;
1483 int py = y * 32;
1484
1485 if (cell->stat_hp)
1486 {
1487 glColor3ub (0, 0, 0);
1488 glRectf (px + 1, py + 1, px + 31, py + 4);
1489
1490 glColor3ub (0, 255, 0);
1491 glBegin (GL_LINES);
1492 glVertex2f (px + 2, py + 2.5f);
1493 glVertex2f (px + 29.f - cell->stat_hp * (28.f / 255.f), py + 2.5f);
1494 glEnd ();
1495 }
1496 }
1497 }
1449} 1498}
1450 1499
1451void 1500void
1452draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1501draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1453 CODE: 1502 CODE:
1533 for (x = 0; x < sw; x++) 1582 for (x = 0; x < sw; x++)
1534 if (row->c0 <= x + vx && x + vx < row->c1) 1583 if (row->c0 <= x + vx && x + vx < row->c1)
1535 { 1584 {
1536 mapcell *cell = row->col + (x + vx - row->c0); 1585 mapcell *cell = row->col + (x + vx - row->c0);
1537 1586
1538 darkness[y * sw4 + x] = cell->darkness < 0 1587 darkness[y * sw4 + x] = cell->darkness
1588 ? 255 - (cell->darkness - 1)
1539 ? 255 - FOW_DARKNESS 1589 : 255 - FOW_DARKNESS;
1540 : 255 - cell->darkness;
1541 } 1590 }
1542 } 1591 }
1543 1592
1544 EXTEND (SP, 3); 1593 EXTEND (SP, 3);
1545 PUSHs (sv_2mortal (newSViv (sw4))); 1594 PUSHs (sv_2mortal (newSViv (sw4)));
1660 1709
1661 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1710 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1662 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1711 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1663 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1712 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1664 1713
1665 if (cell->darkness <= 0) 1714 if (cell->darkness == 0)
1666 { 1715 {
1667 cell->darkness = -1; 1716 cell->darkness = 0;
1668 1717
1669 for (z = 0; z <= 2; z++) 1718 for (z = 0; z <= 2; z++)
1670 { 1719 {
1671 cell->face[z] = face[z]; 1720 cell->face[z] = face[z];
1672 1721

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines