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.145 by root, Fri Aug 18 03:19:58 2006 UTC vs.
Revision 1.149 by root, Sat Aug 19 04:03:15 2006 UTC

171} maptex; 171} maptex;
172 172
173typedef struct { 173typedef struct {
174 uint16_t darkness; 174 uint16_t darkness;
175 mapface face[3]; 175 mapface face[3];
176 uint8_t stat_hp; 176 uint8_t stat_width, stat_hp;
177} mapcell; 177} mapcell;
178 178
179typedef struct { 179typedef struct {
180 int32_t c0, c1; 180 int32_t c0, c1;
181 mapcell *col; 181 mapcell *col;
294static void 294static void
295map_blank (CFPlus__Map self, int x0, int y0, int w, int h) 295map_blank (CFPlus__Map self, int x0, int y0, int w, int h)
296{ 296{
297 int x, y; 297 int x, y;
298 maprow *row; 298 maprow *row;
299 mapcell *cell;
299 300
300 for (y = y0; y < y0 + h; y++) 301 for (y = y0; y < y0 + h; y++)
301 if (y >= 0) 302 if (y >= 0)
302 { 303 {
303 if (y >= self->rows) 304 if (y >= self->rows)
309 if (x >= row->c0) 310 if (x >= row->c0)
310 { 311 {
311 if (x >= row->c1) 312 if (x >= row->c1)
312 break; 313 break;
313 314
314 row->col[x - row->c0].darkness = 0; 315 cell = row->col + x - row->c0;
316
317 cell->darkness = 0;
318 cell->stat_hp = 0;
315 } 319 }
316 } 320 }
317} 321}
318 322
319static void 323static void
1286 { 1290 {
1287 cell->darkness = 256; 1291 cell->darkness = 256;
1288 cell->face [0] = 0; 1292 cell->face [0] = 0;
1289 cell->face [1] = 0; 1293 cell->face [1] = 0;
1290 cell->face [2] = 0; 1294 cell->face [2] = 0;
1291 cell->stat_hp = 0;
1292 } 1295 }
1293 1296
1294 //TODO: don't trust server data to be in-range(!) 1297 //TODO: don't trust server data to be in-range(!)
1295 1298
1296 if (flags & 8) 1299 if (flags & 8)
1302 do 1305 do
1303 { 1306 {
1304 ext = *data++; 1307 ext = *data++;
1305 cmd = ext & 0x3f; 1308 cmd = ext & 0x3f;
1306 1309
1307 if (ext < 4) 1310 if (cmd < 4)
1308 cell->darkness = 255 - ext * 64 + 1; 1311 cell->darkness = 255 - ext * 64 + 1;
1309 else if (ext == 5) // health 1312 else if (cmd == 5) // health
1313 {
1314 cell->stat_width = 1;
1310 cell->stat_hp = *data++; 1315 cell->stat_hp = *data++;
1316 }
1317 else if (cmd == 6) // monster width
1318 cell->stat_width = *data++ + 1;
1311 else if (ext & 0x40) // unknown, multibyte => skip 1319 else if (ext & 0x40) // unknown, multibyte => skip
1312 data += *data + 1; 1320 data += *data + 1;
1321 else
1322 data++;
1313 } 1323 }
1314 while (cmd & 0x80); 1324 while (ext & 0x80);
1315 } 1325 }
1316 else 1326 else
1317 cell->darkness = *data++ + 1; 1327 cell->darkness = *data++ + 1;
1318 } 1328 }
1319 1329
1331 { 1341 {
1332 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1342 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1333 } 1343 }
1334 } 1344 }
1335 else 1345 else
1346 {
1336 cell->darkness = 0; 1347 cell->darkness = 0;
1348 cell->stat_hp = 0;
1349 }
1337 } 1350 }
1338} 1351}
1339 1352
1340SV * 1353SV *
1341mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1354mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1467 } 1480 }
1468 1481
1469 glEnd (); 1482 glEnd ();
1470 1483
1471 glDisable (GL_TEXTURE_2D); 1484 glDisable (GL_TEXTURE_2D);
1472 glDisable (GL_BLEND);
1473 1485
1474 // top layer: overlays such as the health bar 1486 // top layer: overlays such as the health bar
1475 for (y = 0; y < sh; y++) 1487 for (y = 0; y < sh; y++)
1476 if (0 <= y + vy && y + vy < self->rows) 1488 if (0 <= y + vy && y + vy < self->rows)
1477 { 1489 {
1485 int px = x * 32; 1497 int px = x * 32;
1486 int py = y * 32; 1498 int py = y * 32;
1487 1499
1488 if (cell->stat_hp) 1500 if (cell->stat_hp)
1489 { 1501 {
1490 int width = sh / 28 + 1; 1502 int width = cell->stat_width * 32;
1503 int thick = sh / 28 + 1 + cell->stat_width;
1491 1504
1492 glColor3ub (0, 0, 0); 1505 glColor4ub (0, 0, 0, 223);
1493 glRectf (px + 1, py, px + 31, py + width + 2); 1506 glRectf (px + 1, py,
1507 px + width - 1, py + thick + 2);
1494 1508
1495 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); 1509 glColor4ub (cell->stat_hp, 255 - cell->stat_hp, 0, 223);
1496 glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1); 1510 glRectf (px + 2,
1511 py + 1,
1512 px + width - 2 - cell->stat_hp * (width - 4) / 255, py + thick + 1);
1497 } 1513 }
1498 } 1514 }
1499 } 1515 }
1516
1517 glDisable (GL_BLEND);
1500} 1518}
1501 1519
1502void 1520void
1503draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1521draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1504 CODE: 1522 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines