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.179 by root, Wed Apr 11 04:32:51 2007 UTC vs.
Revision 1.186 by root, Sat Apr 21 09:25:31 2007 UTC

345} smooth_key; 345} smooth_key;
346 346
347static void 347static void
348smooth_or_bits (HV *hv, smooth_key *key, IV bits) 348smooth_or_bits (HV *hv, smooth_key *key, IV bits)
349{ 349{
350 SV **sv = hv_fetch (hv, (char *)key, sizeof (key), 1); 350 SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1);
351 351
352 if (SvIOK (*sv)) 352 if (SvIOK (*sv))
353 SvIV_set (*sv, SvIVX (*sv) | bits); 353 SvIV_set (*sv, SvIVX (*sv) | bits);
354 else 354 else
355 sv_setiv (*sv, bits); 355 sv_setiv (*sv, bits);
400 400
401/* SDL should provide this, really. */ 401/* SDL should provide this, really. */
402#define SDLK_MODIFIER_MIN 300 402#define SDLK_MODIFIER_MIN 300
403#define SDLK_MODIFIER_MAX 314 403#define SDLK_MODIFIER_MAX 314
404 404
405static AV *texture_av;
406
405MODULE = CFPlus PACKAGE = CFPlus 407MODULE = CFPlus PACKAGE = CFPlus
406 408
407PROTOTYPES: ENABLE 409PROTOTYPES: ENABLE
408 410
409BOOT: 411BOOT:
410{ 412{
413 texture_av = newAV ();
414 AvREAL_off (texture_av);
415
411 HV *stash = gv_stashpv ("CFPlus", 1); 416 HV *stash = gv_stashpv ("CFPlus", 1);
412 static const struct { 417 static const struct {
413 const char *name; 418 const char *name;
414 IV iv; 419 IV iv;
415 } *civ, const_iv[] = { 420 } *civ, const_iv[] = {
1460 } 1465 }
1461 else if (cmd == 6) // monster width 1466 else if (cmd == 6) // monster width
1462 cell->stat_width = *data++ + 1; 1467 cell->stat_width = *data++ + 1;
1463 else if (cmd == 0x47) 1468 else if (cmd == 0x47)
1464 { 1469 {
1465 if (*data == 8) 1470 if (*data == 4)
1466 ; // decode player uuid 1471 ; // decode player count
1467 1472
1468 data += *data + 1; 1473 data += *data + 1;
1469 } 1474 }
1470 else if (cmd == 8) // cell flags 1475 else if (cmd == 8) // cell flags
1471 cell->flags = *data++; 1476 cell->flags = *data++;
1681 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31); 1686 smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31);
1682 1687
1683 // add bits to current tile and all neighbours. skey.x|y is 1688 // add bits to current tile and all neighbours. skey.x|y is
1684 // shifted +1|+1 so we always stay positive. 1689 // shifted +1|+1 so we always stay positive.
1685 1690
1691 // bits is ___n cccc CCCC bbbb
1692 // n do not draw borders&corners
1693 // c draw these corners, but...
1694 // C ... not these
1695 // b draw these borders
1696
1697 // borders: 1 ┃· 2 ━━ 4 ·┃ 8 ··
1698 // ┃· ·· ·┃ ━━
1699
1700 // corners: 1 ┛· 2 ·┗ 4 ·· 8 ··
1701 // ·· ·· ·┏ ┓·
1702
1686 // full tile 1703 // full tile
1687 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); 1704 skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000);
1688 1705
1689 // borders 1706 // borders
1690 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0031); 1707 skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091);
1691 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0092); 1708 skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032);
1692 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); 1709 skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064);
1693 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); 1710 skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8);
1694 1711
1695 // corners 1712 // corners
1696 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100); 1713 skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100);
1700 } 1717 }
1701 } 1718 }
1702 } 1719 }
1703 } 1720 }
1704 1721
1705 // go through all smoothlevels, lowest to highest, then draw 1722 // go through all smoothlevels, lowest to highest, then draw.
1706 // this is basically counting sort 1723 // this is basically counting sort
1707 { 1724 {
1708 int w, b; 1725 int w, b;
1709 1726
1710 for (w = 0; w < 256 / 32; ++w) 1727 for (w = 0; w < 256 / 32; ++w)
1720 hv_iterinit (smooth); 1737 hv_iterinit (smooth);
1721 while ((he = hv_iternext (smooth))) 1738 while ((he = hv_iternext (smooth)))
1722 { 1739 {
1723 smooth_key *skey = (smooth_key *)HeKEY (he); 1740 smooth_key *skey = (smooth_key *)HeKEY (he);
1724 IV bits = SvIVX (HeVAL (he)); 1741 IV bits = SvIVX (HeVAL (he));
1725
1726 // bits is ___n cccc CCCC bbbb
1727 // n do not draw borders&corners
1728 // c draw these corners, but...
1729 // C ... not these
1730 // b draw these borders
1731 1742
1732 if (!(bits & 0x1000) 1743 if (!(bits & 0x1000)
1733 && skey->level == level 1744 && skey->level == level
1734 && level >= smooth_max [skey->x][skey->y]) 1745 && level >= smooth_max [skey->x][skey->y])
1735 { 1746 {
2364 2375
2365int glGenTexture () 2376int glGenTexture ()
2366 CODE: 2377 CODE:
2367{ 2378{
2368 GLuint name; 2379 GLuint name;
2380 if (AvFILL (texture_av) >= 0)
2381 name = (GLuint)av_pop (texture_av);
2382 else
2369 glGenTextures (1, &name); 2383 glGenTextures (1, &name);
2370 RETVAL = name; 2384 RETVAL = name;
2371} 2385}
2372 OUTPUT: 2386 OUTPUT:
2373 RETVAL 2387 RETVAL
2374 2388
2375void glDeleteTexture (int name) 2389void glDeleteTexture (int name)
2376 CODE: 2390 CODE:
2377{ 2391{
2378 GLuint name_ = name; 2392 /* make a half-assed attempt at returning the memory used by the texture */
2393 /* textures are frequently being reused by cfplus anyway */
2394 glBindTexture (GL_TEXTURE_2D, name);
2395 glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, 0, 0, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0);
2396 av_push (texture_av, (SV *)name);
2379 glDeleteTextures (1, &name_); 2397 /*glDeleteTextures (1, &name_);*/
2380} 2398}
2381 2399
2382int glGenList () 2400int glGenList ()
2383 CODE: 2401 CODE:
2384 RETVAL = glGenLists (1); 2402 RETVAL = glGenLists (1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines