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.146 by root, Sat Aug 19 02:49:53 2006 UTC vs.
Revision 1.155 by root, Thu Sep 21 00:16:42 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;
314 315
315 cell = row->col + x - row->c0; 316 cell = row->col + x - row->c0;
316 317
317 cell->darkness = 0; 318 cell->darkness = 0;
318 cell->stat_hp = 0; 319 cell->stat_hp = 0;
320 cell->flags = 0;
321 cell->player = 0;
319 } 322 }
320 } 323 }
321} 324}
322 325
323static void 326static void
1243void 1246void
1244scroll (CFPlus::Map self, int dx, int dy) 1247scroll (CFPlus::Map self, int dx, int dy)
1245 CODE: 1248 CODE:
1246{ 1249{
1247 if (dx > 0) 1250 if (dx > 0)
1248 map_blank (self, self->x, self->y, dx - 1, self->h); 1251 map_blank (self, self->x, self->y, dx, self->h);
1249 else if (dx < 0) 1252 else if (dx < 0)
1250 map_blank (self, self->x + self->w + dx + 1, self->y, 1 - dx, self->h); 1253 map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h);
1251 1254
1252 if (dy > 0) 1255 if (dy > 0)
1253 map_blank (self, self->x, self->y, self->w, dy - 1); 1256 map_blank (self, self->x, self->y, self->w, dy);
1254 else if (dy < 0) 1257 else if (dy < 0)
1255 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, 1 - dy); 1258 map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy);
1256 1259
1257 self->ox += dx; self->x += dx; 1260 self->ox += dx; self->x += dx;
1258 self->oy += dy; self->y += dy; 1261 self->oy += dy; self->y += dy;
1259 1262
1260 while (self->y < 0) 1263 while (self->y < 0)
1273 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1276 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1274 uint8_t *data_end = (uint8_t *)SvEND (data_); 1277 uint8_t *data_end = (uint8_t *)SvEND (data_);
1275 mapcell *cell; 1278 mapcell *cell;
1276 int x, y, flags; 1279 int x, y, flags;
1277 1280
1278 while (data < data_end) 1281 while (data < data_end - 1)
1279 { 1282 {
1280 flags = (data [0] << 8) + data [1]; data += 2; 1283 flags = (data [0] << 8) + data [1]; data += 2;
1281 1284
1282 x = self->x + ((flags >> 10) & 63); 1285 x = self->x + ((flags >> 10) & 63);
1283 y = self->y + ((flags >> 4) & 63); 1286 y = self->y + ((flags >> 4) & 63);
1286 1289
1287 if (flags & 15) 1290 if (flags & 15)
1288 { 1291 {
1289 if (!cell->darkness) 1292 if (!cell->darkness)
1290 { 1293 {
1294 memset (cell, 0, sizeof (*cell));
1291 cell->darkness = 256; 1295 cell->darkness = 256;
1292 cell->face [0] = 0;
1293 cell->face [1] = 0;
1294 cell->face [2] = 0;
1295 } 1296 }
1296 1297
1297 //TODO: don't trust server data to be in-range(!) 1298 //TODO: don't trust server data to be in-range(!)
1298 1299
1299 if (flags & 8) 1300 if (flags & 8)
1305 do 1306 do
1306 { 1307 {
1307 ext = *data++; 1308 ext = *data++;
1308 cmd = ext & 0x3f; 1309 cmd = ext & 0x3f;
1309 1310
1310 if (ext < 4) 1311 if (cmd < 4)
1311 cell->darkness = 255 - ext * 64 + 1; 1312 cell->darkness = 255 - ext * 64 + 1;
1312 else if (ext == 5) // health 1313 else if (cmd == 5) // health
1314 {
1315 cell->stat_width = 1;
1313 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++;
1314 else if (ext & 0x40) // unknown, multibyte => skip 1329 else if (ext & 0x40) // unknown, multibyte => skip
1315 data += *data + 1; 1330 data += *data + 1;
1331 else
1332 data++;
1316 } 1333 }
1317 while (cmd & 0x80); 1334 while (ext & 0x80);
1318 } 1335 }
1319 else 1336 else
1320 cell->darkness = *data++ + 1; 1337 cell->darkness = *data++ + 1;
1338
1321 } 1339 }
1322 1340
1323 if (flags & 4) 1341 if (flags & 4)
1324 { 1342 {
1325 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1343 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1334 { 1352 {
1335 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1353 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1336 } 1354 }
1337 } 1355 }
1338 else 1356 else
1339 {
1340 cell->darkness = 0; 1357 cell->darkness = 0;
1341 cell->stat_hp = 0;
1342 }
1343 } 1358 }
1344} 1359}
1345 1360
1346SV * 1361SV *
1347mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1362mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1450 face = cell->face [z]; 1465 face = cell->face [z];
1451 1466
1452 if (face && face < self->texs) 1467 if (face && face < self->texs)
1453 { 1468 {
1454 maptex tex = self->tex [face]; 1469 maptex tex = self->tex [face];
1455
1456 int px = (x + 1) * 32 - tex.w; 1470 int px = (x + 1) * 32 - tex.w;
1457 int py = (y + 1) * 32 - tex.h; 1471 int py = (y + 1) * 32 - tex.h;
1458 1472
1459 if (last_name != tex.name) 1473 if (last_name != tex.name)
1460 { 1474 {
1461 glEnd (); 1475 glEnd ();
1462 last_name = tex.name;
1463 glBindTexture (GL_TEXTURE_2D, last_name); 1476 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1464 glBegin (GL_QUADS); 1477 glBegin (GL_QUADS);
1465 } 1478 }
1466 1479
1467 glTexCoord2f (0 , 0 ); glVertex2f (px , py ); 1480 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1468 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); 1481 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1469 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); 1482 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1470 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py ); 1483 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1471 } 1484 }
1485
1486 if (cell->flags && z == 2)
1487 {
1488 if (cell->flags & 1)
1489 {
1490 maptex tex = self->tex [1];
1491 int px = (x + 1) * 32 - tex.w + 2;
1492 int py = (y + 1) * 32 - tex.h - 6;
1493
1494 glEnd ();
1495 glBindTexture (GL_TEXTURE_2D, last_name = tex.name);
1496 glBegin (GL_QUADS);
1497
1498 glTexCoord2f (0 , 0 ); glVertex2f (px , py );
1499 glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h);
1500 glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h);
1501 glTexCoord2f (tex.s, 0 ); glVertex2f (px + tex.w, py );
1502 }
1503 }
1472 } 1504 }
1473 } 1505 }
1474 1506
1475 glEnd (); 1507 glEnd ();
1476 1508
1491 int px = x * 32; 1523 int px = x * 32;
1492 int py = y * 32; 1524 int py = y * 32;
1493 1525
1494 if (cell->stat_hp) 1526 if (cell->stat_hp)
1495 { 1527 {
1496 int width = sh / 28 + 1; 1528 int width = cell->stat_width * 32;
1529 int thick = sh / 28 + 1 + cell->stat_width;
1497 1530
1498 glColor3ub (0, 0, 0); 1531 glColor3ub (0, 0, 0);
1499 glRectf (px + 1, py, px + 31, py + width + 2); 1532 glRectf (px + 1, py - thick - 2,
1533 px + width - 1, py);
1500 1534
1501 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0); 1535 glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
1502 glRectf (px + 2, py + 1, px + 30 - cell->stat_hp * 28 / 255, py + width + 1); 1536 glRectf (px + 2,
1537 py - thick - 1,
1538 px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
1503 } 1539 }
1504 } 1540 }
1505 } 1541 }
1506} 1542}
1507 1543

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines