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.139 by root, Mon Aug 14 03:04:17 2006 UTC vs.
Revision 1.145 by root, Fri Aug 18 03:19:58 2006 UTC

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
166typedef uint16_t mapface; 164typedef 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
175typedef struct { 173typedef 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
180typedef struct { 179typedef 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
320static void 319static void
1262 self->y += MAP_EXTEND_Y; 1261 self->y += MAP_EXTEND_Y;
1263 } 1262 }
1264} 1263}
1265 1264
1266void 1265void
1267map1a_update (CFPlus::Map self, SV *data_) 1266map1a_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;
1291 cell->stat_hp = 0;
1292 } 1292 }
1293 1293
1294 cell->darkness = flags & 8 ? *data++ : 255;
1295
1296 //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 & 0x3f;
1306
1307 if (ext < 4)
1308 cell->darkness = 255 - ext * 64 + 1;
1309 else if (ext == 5) // health
1310 cell->stat_hp = *data++;
1311 else if (ext & 0x40) // unknown, multibyte => skip
1312 data += *data + 1;
1313 }
1314 while (cmd & 0x80);
1315 }
1316 else
1317 cell->darkness = *data++ + 1;
1318 }
1297 1319
1298 if (flags & 4) 1320 if (flags & 4)
1299 { 1321 {
1300 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1322 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1301 } 1323 }
1309 { 1331 {
1310 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1332 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1311 } 1333 }
1312 } 1334 }
1313 else 1335 else
1314 cell->darkness = -1; 1336 cell->darkness = 0;
1315 } 1337 }
1316} 1338}
1317 1339
1318SV * 1340SV *
1319mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1341mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1419 { 1441 {
1420 mapcell *cell = row->col + (x + vx - row->c0); 1442 mapcell *cell = row->col + (x + vx - row->c0);
1421 1443
1422 face = cell->face [z]; 1444 face = cell->face [z];
1423 1445
1424 if (face) 1446 if (face && face < self->texs)
1425 { 1447 {
1426 maptex tex = self->tex [face]; 1448 maptex tex = self->tex [face];
1427 1449
1428 int px = (x + 1) * 32 - tex.w; 1450 int px = (x + 1) * 32 - tex.w;
1429 int py = (y + 1) * 32 - tex.h; 1451 int py = (y + 1) * 32 - tex.h;
1446 1468
1447 glEnd (); 1469 glEnd ();
1448 1470
1449 glDisable (GL_TEXTURE_2D); 1471 glDisable (GL_TEXTURE_2D);
1450 glDisable (GL_BLEND); 1472 glDisable (GL_BLEND);
1473
1474 // top layer: overlays such as the health bar
1475 for (y = 0; y < sh; y++)
1476 if (0 <= y + vy && y + vy < self->rows)
1477 {
1478 maprow *row = self->row + (y + vy);
1479
1480 for (x = 0; x < sw; x++)
1481 if (row->c0 <= x + vx && x + vx < row->c1)
1482 {
1483 mapcell *cell = row->col + (x + vx - row->c0);
1484
1485 int px = x * 32;
1486 int py = y * 32;
1487
1488 if (cell->stat_hp)
1489 {
1490 int width = sh / 28 + 1;
1491
1492 glColor3ub (0, 0, 0);
1493 glRectf (px + 1, py, px + 31, py + width + 2);
1494
1495 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
1496 glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1);
1497 }
1498 }
1499 }
1451} 1500}
1452 1501
1453void 1502void
1454draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1503draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1455 CODE: 1504 CODE:
1535 for (x = 0; x < sw; x++) 1584 for (x = 0; x < sw; x++)
1536 if (row->c0 <= x + vx && x + vx < row->c1) 1585 if (row->c0 <= x + vx && x + vx < row->c1)
1537 { 1586 {
1538 mapcell *cell = row->col + (x + vx - row->c0); 1587 mapcell *cell = row->col + (x + vx - row->c0);
1539 1588
1540 darkness[y * sw4 + x] = cell->darkness < 0 1589 darkness[y * sw4 + x] = cell->darkness
1590 ? 255 - (cell->darkness - 1)
1541 ? 255 - FOW_DARKNESS 1591 : 255 - FOW_DARKNESS;
1542 : 255 - cell->darkness;
1543 } 1592 }
1544 } 1593 }
1545 1594
1546 EXTEND (SP, 3); 1595 EXTEND (SP, 3);
1547 PUSHs (sv_2mortal (newSViv (sw4))); 1596 PUSHs (sv_2mortal (newSViv (sw4)));
1662 1711
1663 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1712 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1664 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1713 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1665 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1714 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1666 1715
1667 if (cell->darkness <= 0) 1716 if (cell->darkness == 0)
1668 { 1717 {
1669 cell->darkness = -1; 1718 cell->darkness = 0;
1670 1719
1671 for (z = 0; z <= 2; z++) 1720 for (z = 0; z <= 2; z++)
1672 { 1721 {
1673 cell->face[z] = face[z]; 1722 cell->face[z] = face[z];
1674 1723

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines