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.133 by root, Sun Jul 30 13:16:44 2006 UTC vs.
Revision 1.143 by root, Fri Aug 18 02:23:39 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
512 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0); 520 SDL_GL_SetAttribute (SDL_GL_ACCUM_GREEN_SIZE, 0);
513 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0); 521 SDL_GL_SetAttribute (SDL_GL_ACCUM_BLUE_SIZE, 0);
514 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0); 522 SDL_GL_SetAttribute (SDL_GL_ACCUM_ALPHA_SIZE, 0);
515 523
516 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); 524 SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
525#if SDL_VERSION_ATLEAST(1,2,10)
517 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1); 526 SDL_GL_SetAttribute (SDL_GL_ACCELERATED_VISUAL, 1);
518 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1); 527 SDL_GL_SetAttribute (SDL_GL_SWAP_CONTROL, 1);
528#endif
519 529
520 SDL_EnableUNICODE (1); 530 SDL_EnableUNICODE (1);
521 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); 531 SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
522 532
523 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL); 533 m = SDL_ListModes (0, SDL_FULLSCREEN | SDL_OPENGL);
1023 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); 1033 PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE)));
1024 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); 1034 PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE)));
1025} 1035}
1026 1036
1027void 1037void
1028render (CFPlus::Layout self, float x, float y) 1038render (CFPlus::Layout self, float x, float y, int flags = 0)
1029 PPCODE: 1039 PPCODE:
1030 pango_opengl_render_layout_subpixel ( 1040 pango_opengl_render_layout_subpixel (
1031 self->pl, 1041 self->pl,
1032 x * PANGO_SCALE, y * PANGO_SCALE, 1042 x * PANGO_SCALE, y * PANGO_SCALE,
1033 self->r, self->g, self->b, self->a 1043 self->r, self->g, self->b, self->a,
1044 flags
1034 ); 1045 );
1035 1046
1036MODULE = CFPlus PACKAGE = CFPlus::Texture 1047MODULE = CFPlus PACKAGE = CFPlus::Texture
1037 1048
1038void 1049void
1250 self->y += MAP_EXTEND_Y; 1261 self->y += MAP_EXTEND_Y;
1251 } 1262 }
1252} 1263}
1253 1264
1254void 1265void
1255map1a_update (CFPlus::Map self, SV *data_) 1266map1a_update (CFPlus::Map self, SV *data_, int extmap)
1256 CODE: 1267 CODE:
1257{ 1268{
1258 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); 1269 uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_);
1259 uint8_t *data_end = (uint8_t *)SvEND (data_); 1270 uint8_t *data_end = (uint8_t *)SvEND (data_);
1260 mapcell *cell; 1271 mapcell *cell;
1269 1280
1270 cell = map_get_cell (self, x, y); 1281 cell = map_get_cell (self, x, y);
1271 1282
1272 if (flags & 15) 1283 if (flags & 15)
1273 { 1284 {
1274 if (cell->darkness < 0) 1285 if (!cell->darkness)
1275 { 1286 {
1276 cell->darkness = 0; 1287 cell->darkness = 256;
1277 cell->face [0] = 0; 1288 cell->face [0] = 0;
1278 cell->face [1] = 0; 1289 cell->face [1] = 0;
1279 cell->face [2] = 0; 1290 cell->face [2] = 0;
1291 cell->stat_hp = 0;
1280 } 1292 }
1281 1293
1282 cell->darkness = flags & 8 ? *data++ : 255;
1283
1284 //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 & 0x7f;
1306
1307 if (ext < 4)
1308 cell->darkness = 255 - ext * 64 + 1;
1309 else if (ext == 5) // health
1310 cell->stat_hp = *data++;
1311 }
1312 while (cmd & 0x80);
1313 }
1314 else
1315 cell->darkness = *data++ + 1;
1316 }
1285 1317
1286 if (flags & 4) 1318 if (flags & 4)
1287 { 1319 {
1288 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2; 1320 cell->face [0] = self->face [(data [0] << 8) + data [1]]; data += 2;
1289 } 1321 }
1297 { 1329 {
1298 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2; 1330 cell->face [2] = self->face [(data [0] << 8) + data [1]]; data += 2;
1299 } 1331 }
1300 } 1332 }
1301 else 1333 else
1302 cell->darkness = -1; 1334 cell->darkness = 0;
1303 } 1335 }
1304} 1336}
1305 1337
1306SV * 1338SV *
1307mapmap (CFPlus::Map self, int x0, int y0, int w, int h) 1339mapmap (CFPlus::Map self, int x0, int y0, int w, int h)
1434 1466
1435 glEnd (); 1467 glEnd ();
1436 1468
1437 glDisable (GL_TEXTURE_2D); 1469 glDisable (GL_TEXTURE_2D);
1438 glDisable (GL_BLEND); 1470 glDisable (GL_BLEND);
1471
1472 for (y = 0; y < sh; y++)
1473 if (0 <= y + vy && y + vy < self->rows)
1474 {
1475 maprow *row = self->row + (y + vy);
1476
1477 for (x = 0; x < sw; x++)
1478 if (row->c0 <= x + vx && x + vx < row->c1)
1479 {
1480 mapcell *cell = row->col + (x + vx - row->c0);
1481
1482 int px = x * 32;
1483 int py = y * 32;
1484
1485 if (cell->stat_hp)
1486 {
1487 glColor3ub (0, 0, 0);
1488 glRectf (px + 1, py + 1, px + 31, py + 4);
1489
1490 glColor3ub (0, 255, 0);
1491 glBegin (GL_LINES);
1492 glVertex2f (px + 2, py + 2.5f);
1493 glVertex2f (px + 29.f - cell->stat_hp * (28.f / 255.f), py + 2.5f);
1494 glEnd ();
1495 }
1496 }
1497 }
1439} 1498}
1440 1499
1441void 1500void
1442draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data) 1501draw_magicmap (CFPlus::Map self, int dx, int dy, int w, int h, unsigned char *data)
1443 CODE: 1502 CODE:
1523 for (x = 0; x < sw; x++) 1582 for (x = 0; x < sw; x++)
1524 if (row->c0 <= x + vx && x + vx < row->c1) 1583 if (row->c0 <= x + vx && x + vx < row->c1)
1525 { 1584 {
1526 mapcell *cell = row->col + (x + vx - row->c0); 1585 mapcell *cell = row->col + (x + vx - row->c0);
1527 1586
1528 darkness[y * sw4 + x] = cell->darkness < 0 1587 darkness[y * sw4 + x] = cell->darkness
1588 ? 255 - (cell->darkness - 1)
1529 ? 255 - FOW_DARKNESS 1589 : 255 - FOW_DARKNESS;
1530 : 255 - cell->darkness;
1531 } 1590 }
1532 } 1591 }
1533 1592
1534 EXTEND (SP, 3); 1593 EXTEND (SP, 3);
1535 PUSHs (sv_2mortal (newSViv (sw4))); 1594 PUSHs (sv_2mortal (newSViv (sw4)));
1650 1709
1651 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; } 1710 if (flags & 1) { face[0] = *data++ << 8; face[0] |= *data++; }
1652 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; } 1711 if (flags & 2) { face[1] = *data++ << 8; face[1] |= *data++; }
1653 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; } 1712 if (flags & 4) { face[2] = *data++ << 8; face[2] |= *data++; }
1654 1713
1655 if (cell->darkness <= 0) 1714 if (cell->darkness == 0)
1656 { 1715 {
1657 cell->darkness = -1; 1716 cell->darkness = 0;
1658 1717
1659 for (z = 0; z <= 2; z++) 1718 for (z = 0; z <= 2; z++)
1660 { 1719 {
1661 cell->face[z] = face[z]; 1720 cell->face[z] = face[z];
1662 1721
1800 const_iv (GL_SEPARABLE_2D), 1859 const_iv (GL_SEPARABLE_2D),
1801 const_iv (GL_CONVOLUTION_2D), 1860 const_iv (GL_CONVOLUTION_2D),
1802 const_iv (GL_CONVOLUTION_BORDER_MODE), 1861 const_iv (GL_CONVOLUTION_BORDER_MODE),
1803 const_iv (GL_CONSTANT_BORDER), 1862 const_iv (GL_CONSTANT_BORDER),
1804 const_iv (GL_LINES), 1863 const_iv (GL_LINES),
1864 const_iv (GL_LINE_STRIP),
1805 const_iv (GL_LINE_LOOP), 1865 const_iv (GL_LINE_LOOP),
1806 const_iv (GL_QUADS), 1866 const_iv (GL_QUADS),
1807 const_iv (GL_QUAD_STRIP), 1867 const_iv (GL_QUAD_STRIP),
1808 const_iv (GL_TRIANGLES), 1868 const_iv (GL_TRIANGLES),
1809 const_iv (GL_TRIANGLE_STRIP), 1869 const_iv (GL_TRIANGLE_STRIP),
2006 2066
2007void glEndList () 2067void glEndList ()
2008 2068
2009void glCallList (int list) 2069void glCallList (int list)
2010 2070
2011

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines