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.141 by root, Fri Aug 18 01:01:00 2006 UTC vs.
Revision 1.142 by root, Fri Aug 18 01:27:15 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
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;
1290 } 1291 }
1291 1292
1293 //TODO: don't trust server data to be in-range(!)
1294
1292 if (flags & 8) 1295 if (flags & 8)
1293 { 1296 {
1294 fprintf (stderr, "oi\n");//D
1295 if (extmap) 1297 if (extmap)
1296 { 1298 {
1297 uint8_t ext, cmd; 1299 uint8_t ext, cmd;
1298 1300
1299 do 1301 do
1300 { 1302 {
1301
1302 ext = *data++; 1303 ext = *data++;
1303 cmd = ext & 0x7f; 1304 cmd = ext & 0x7f;
1304 1305
1305 fprintf (stderr, "extcmd = %x\n", ext);//D
1306
1307 if (ext < 4) 1306 if (ext < 4)
1308 cell->darkness = 255 - ext * 64; 1307 cell->darkness = 255 - ext * 64 + 1;
1308 else if (ext == 5) // health
1309 cell->stat_hp = *data++;
1309 } 1310 }
1310 while (cmd & 0x80); 1311 while (cmd & 0x80);
1311 } 1312 }
1312 else 1313 else
1313 cell->darkness = flags & 8 ? *data++ : 255; 1314 cell->darkness = *data++ + 1;
1314 } 1315 }
1315
1316 //TODO: don't trust server data to be in-range(!)
1317 1316
1318 if (flags & 4) 1317 if (flags & 4)
1319 { 1318 {
1320 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1319 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1321 } 1320 }
1329 { 1328 {
1330 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1329 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1331 } 1330 }
1332 } 1331 }
1333 else 1332 else
1334 cell->darkness = -1; 1333 cell->darkness = 0;
1335 } 1334 }
1336} 1335}
1337 1336
1338SV * 1337SV *
1339mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1338mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1555 for (x = 0; x < sw; x++) 1554 for (x = 0; x < sw; x++)
1556 if (row->c0 <= x + vx && x + vx < row->c1) 1555 if (row->c0 <= x + vx && x + vx < row->c1)
1557 { 1556 {
1558 mapcell *cell = row->col + (x + vx - row->c0); 1557 mapcell *cell = row->col + (x + vx - row->c0);
1559 1558
1560 darkness[y * sw4 + x] = cell->darkness < 0 1559 darkness[y * sw4 + x] = cell->darkness
1560 ? 255 - cell->darkness + 1
1561 ? 255 - FOW_DARKNESS 1561 : 255 - FOW_DARKNESS;
1562 : 255 - cell->darkness;
1563 } 1562 }
1564 } 1563 }
1565 1564
1566 EXTEND (SP, 3); 1565 EXTEND (SP, 3);
1567 PUSHs (sv_2mortal (newSViv (sw4))); 1566 PUSHs (sv_2mortal (newSViv (sw4)));
1682 1681
1683 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1682 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1684 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1683 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1685 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1684 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1686 1685
1687 if (cell->darkness <= 0) 1686 if (cell->darkness <= 1)
1688 { 1687 {
1689 cell->darkness = -1; 1688 cell->darkness = 0;
1690 1689
1691 for (z = 0; z <= 2; z++) 1690 for (z = 0; z <= 2; z++)
1692 { 1691 {
1693 cell->face[z] = face[z]; 1692 cell->face[z] = face[z];
1694 1693

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines