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.134 by root, Fri Aug 4 16:49:58 2006 UTC vs.
Revision 1.142 by root, Fri Aug 18 01:27:15 2006 UTC

144} 144}
145 145
146static void 146static void
147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h) 147layout_get_pixel_size (CFPlus__Layout self, int *w, int *h)
148{ 148{
149 PangoRectangle rect;
150
151 // get_pixel_* wrongly rounds down
149 pango_layout_get_pixel_size (self->pl, w, h); 152 pango_layout_get_extents (self->pl, 0, &rect);
150 153
151 if (!*w) *w = 1; 154 rect.width = (rect.width + PANGO_SCALE - 1) / PANGO_SCALE;
152 if (!*h) *h = 1; 155 rect.height = (rect.height + PANGO_SCALE - 1) / PANGO_SCALE;
153 156
154 *w = (*w + 3) & ~3; 157 if (!rect.width) rect.width = 1;
158 if (!rect.height) rect.height = 1;
159
160 *w = rect.width;
161 *h = rect.height;
155} 162}
156 163
157typedef uint16_t mapface; 164typedef uint16_t mapface;
158 165
159typedef struct { 166typedef struct {
162 float s, t; 169 float s, t;
163 uint8_t r, g, b, a; 170 uint8_t r, g, b, a;
164} maptex; 171} maptex;
165 172
166typedef struct { 173typedef struct {
167 int16_t darkness; 174 uint16_t darkness;
168 mapface face[3]; 175 mapface face[3];
176 uint8_t stat_hp;
169} mapcell; 177} mapcell;
170 178
171typedef struct { 179typedef struct {
172 int32_t c0, c1; 180 int32_t c0, c1;
173 mapcell *col; 181 mapcell *col;
301 if (x >= row->c0) 309 if (x >= row->c0)
302 { 310 {
303 if (x >= row->c1) 311 if (x >= row->c1)
304 break; 312 break;
305 313
306 row->col[x - row->c0].darkness = -1; 314 row->col[x - row->c0].darkness = 0;
307 } 315 }
308 } 316 }
309} 317}
310 318
311static void 319static void
1025 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1033 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1026 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1034 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1027} 1035}
1028 1036
1029void 1037void
1030render (CFPlus::Layout self, float x, float y) 1038render (CFPlus::Layout self, float x, float y, int flags = 0)
1031 PPCODE: 1039 PPCODE:
1032 pango_opengl_render_layout_subpixel ( 1040 pango_opengl_render_layout_subpixel (
1033 self->pl, 1041 self->pl,
1034 x * PANGO_SCALE, y * PANGO_SCALE, 1042 x * PANGO_SCALE, y * PANGO_SCALE,
1035 self->r, self->g, self->b, self->a 1043 self->r, self->g, self->b, self->a,
1044 flags
1036 ); 1045 );
1037 1046
1038MODULE = CFPlus PACKAGE = CFPlus::Texture 1047MODULE = CFPlus PACKAGE = CFPlus::Texture
1039 1048
1040void 1049void
1252 self->y += MAP_EXTEND_Y; 1261 self->y += MAP_EXTEND_Y;
1253 } 1262 }
1254} 1263}
1255 1264
1256void 1265void
1257map1a_update (CFPlus::Map self, SV *data_) 1266map1a_update (CFPlus::Map self, SV *data_, int extmap)
1258 CODE: 1267 CODE:
1259{ 1268{
1260 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1269 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1261 uint8_t *data_end = (uint8_t *)SvEND (data_); 1270 uint8_t *data_end = (uint8_t *)SvEND (data_);
1262 mapcell *cell; 1271 mapcell *cell;
1271 1280
1272 cell = map_get_cell (self, x, y); 1281 cell = map_get_cell (self, x, y);
1273 1282
1274 if (flags & 15) 1283 if (flags & 15)
1275 { 1284 {
1276 if (cell->darkness < 0) 1285 if (!cell->darkness)
1277 { 1286 {
1278 cell->darkness = 0; 1287 cell->darkness = 256;
1279 cell->face [0] = 0; 1288 cell->face [0] = 0;
1280 cell->face [1] = 0; 1289 cell->face [1] = 0;
1281 cell->face [2] = 0; 1290 cell->face [2] = 0;
1282 } 1291 }
1283 1292
1284 cell->darkness = flags & 8 ? *data++ : 255;
1285
1286 //TODO: don't trust server data to be in-range(!) 1293 //TODO: don't trust server data to be in-range(!)
1294
1295 if (flags & 8)
1296 {
1297 if (extmap)
1298 {
1299 uint8_t ext, cmd;
1300
1301 do
1302 {
1303 ext = *data++;
1304 cmd = ext & 0x7f;
1305
1306 if (ext < 4)
1307 cell->darkness = 255 - ext * 64 + 1;
1308 else if (ext == 5) // health
1309 cell->stat_hp = *data++;
1310 }
1311 while (cmd & 0x80);
1312 }
1313 else
1314 cell->darkness = *data++ + 1;
1315 }
1287 1316
1288 if (flags & 4) 1317 if (flags & 4)
1289 { 1318 {
1290 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;
1291 } 1320 }
1299 { 1328 {
1300 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;
1301 } 1330 }
1302 } 1331 }
1303 else 1332 else
1304 cell->darkness = -1; 1333 cell->darkness = 0;
1305 } 1334 }
1306} 1335}
1307 1336
1308SV * 1337SV *
1309mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1338mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1525 for (x = 0; x < sw; x++) 1554 for (x = 0; x < sw; x++)
1526 if (row->c0 <= x + vx && x + vx < row->c1) 1555 if (row->c0 <= x + vx && x + vx < row->c1)
1527 { 1556 {
1528 mapcell *cell = row->col + (x + vx - row->c0); 1557 mapcell *cell = row->col + (x + vx - row->c0);
1529 1558
1530 darkness[y * sw4 + x] = cell->darkness < 0 1559 darkness[y * sw4 + x] = cell->darkness
1560 ? 255 - cell->darkness + 1
1531 ? 255 - FOW_DARKNESS 1561 : 255 - FOW_DARKNESS;
1532 : 255 - cell->darkness;
1533 } 1562 }
1534 } 1563 }
1535 1564
1536 EXTEND (SP, 3); 1565 EXTEND (SP, 3);
1537 PUSHs (sv_2mortal (newSViv (sw4))); 1566 PUSHs (sv_2mortal (newSViv (sw4)));
1652 1681
1653 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1682 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1654 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1683 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1655 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1684 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1656 1685
1657 if (cell->darkness <= 0) 1686 if (cell->darkness <= 1)
1658 { 1687 {
1659 cell->darkness = -1; 1688 cell->darkness = 0;
1660 1689
1661 for (z = 0; z <= 2; z++) 1690 for (z = 0; z <= 2; z++)
1662 { 1691 {
1663 cell->face[z] = face[z]; 1692 cell->face[z] = face[z];
1664 1693
1802 const_iv (GL_SEPARABLE_2D), 1831 const_iv (GL_SEPARABLE_2D),
1803 const_iv (GL_CONVOLUTION_2D), 1832 const_iv (GL_CONVOLUTION_2D),
1804 const_iv (GL_CONVOLUTION_BORDER_MODE), 1833 const_iv (GL_CONVOLUTION_BORDER_MODE),
1805 const_iv (GL_CONSTANT_BORDER), 1834 const_iv (GL_CONSTANT_BORDER),
1806 const_iv (GL_LINES), 1835 const_iv (GL_LINES),
1836 const_iv (GL_LINE_STRIP),
1807 const_iv (GL_LINE_LOOP), 1837 const_iv (GL_LINE_LOOP),
1808 const_iv (GL_QUADS), 1838 const_iv (GL_QUADS),
1809 const_iv (GL_QUAD_STRIP), 1839 const_iv (GL_QUAD_STRIP),
1810 const_iv (GL_TRIANGLES), 1840 const_iv (GL_TRIANGLES),
1811 const_iv (GL_TRIANGLE_STRIP), 1841 const_iv (GL_TRIANGLE_STRIP),
2008 2038
2009void glEndList () 2039void glEndList ()
2010 2040
2011void glCallList (int list) 2041void glCallList (int list)
2012 2042
2013

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines