… | |
… | |
55 | #if 0 |
55 | #if 0 |
56 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
56 | # define PARACHUTE SDL_INIT_NOPARACHUTE |
57 | #else |
57 | #else |
58 | # define PARACHUTE 0 |
58 | # define PARACHUTE 0 |
59 | #endif |
59 | #endif |
|
|
60 | |
|
|
61 | static AV *texture_av; |
60 | |
62 | |
61 | static struct |
63 | static struct |
62 | { |
64 | { |
63 | #define GL_FUNC(ptr,name) ptr name; |
65 | #define GL_FUNC(ptr,name) ptr name; |
64 | #include "glfunc.h" |
66 | #include "glfunc.h" |
… | |
… | |
345 | } smooth_key; |
347 | } smooth_key; |
346 | |
348 | |
347 | static void |
349 | static void |
348 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
350 | smooth_or_bits (HV *hv, smooth_key *key, IV bits) |
349 | { |
351 | { |
350 | SV **sv = hv_fetch (hv, (char *)key, sizeof (key), 1); |
352 | SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); |
351 | |
353 | |
352 | if (SvIOK (*sv)) |
354 | if (SvIOK (*sv)) |
353 | SvIV_set (*sv, SvIVX (*sv) | bits); |
355 | SvIV_set (*sv, SvIVX (*sv) | bits); |
354 | else |
356 | else |
355 | sv_setiv (*sv, bits); |
357 | sv_setiv (*sv, bits); |
… | |
… | |
614 | RETVAL = !!SDL_SetVideoMode ( |
616 | RETVAL = !!SDL_SetVideoMode ( |
615 | w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) |
617 | w, h, 0, SDL_OPENGL | (fullscreen ? SDL_FULLSCREEN : 0) |
616 | ); |
618 | ); |
617 | if (RETVAL) |
619 | if (RETVAL) |
618 | { |
620 | { |
|
|
621 | av_clear (texture_av); |
|
|
622 | |
619 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
623 | SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); |
620 | # define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
624 | # define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); |
621 | # include "glfunc.h" |
625 | # include "glfunc.h" |
622 | # undef GL_FUNC |
626 | # undef GL_FUNC |
|
|
627 | |
623 | } |
628 | } |
624 | OUTPUT: |
629 | OUTPUT: |
625 | RETVAL |
630 | RETVAL |
626 | |
631 | |
627 | void |
632 | void |
… | |
… | |
1391 | CODE: |
1396 | CODE: |
1392 | { |
1397 | { |
1393 | if (dx > 0) |
1398 | if (dx > 0) |
1394 | map_blank (self, self->x, self->y, dx, self->h); |
1399 | map_blank (self, self->x, self->y, dx, self->h); |
1395 | else if (dx < 0) |
1400 | else if (dx < 0) |
1396 | map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); |
1401 | map_blank (self, self->x + self->w + dx, self->y, -dx, self->h); |
1397 | |
1402 | |
1398 | if (dy > 0) |
1403 | if (dy > 0) |
1399 | map_blank (self, self->x, self->y, self->w, dy); |
1404 | map_blank (self, self->x, self->y, self->w, dy); |
1400 | else if (dy < 0) |
1405 | else if (dy < 0) |
1401 | map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); |
1406 | map_blank (self, self->x, self->y + self->h + dy, self->w, -dy); |
1402 | |
1407 | |
1403 | self->ox += dx; self->x += dx; |
1408 | self->ox += dx; self->x += dx; |
1404 | self->oy += dy; self->y += dy; |
1409 | self->oy += dy; self->y += dy; |
1405 | |
1410 | |
1406 | while (self->y < 0) |
1411 | while (self->y < 0) |
… | |
… | |
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 | { |
… | |
… | |
2204 | # undef const_iv |
2215 | # undef const_iv |
2205 | }; |
2216 | }; |
2206 | |
2217 | |
2207 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2218 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
2208 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
2219 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
2220 | |
|
|
2221 | texture_av = newAV (); |
|
|
2222 | AvREAL_off (texture_av); |
2209 | } |
2223 | } |
2210 | |
2224 | |
2211 | char * |
2225 | char * |
2212 | gl_vendor () |
2226 | gl_vendor () |
2213 | CODE: |
2227 | CODE: |
… | |
… | |
2364 | |
2378 | |
2365 | int glGenTexture () |
2379 | int glGenTexture () |
2366 | CODE: |
2380 | CODE: |
2367 | { |
2381 | { |
2368 | GLuint name; |
2382 | GLuint name; |
|
|
2383 | if (AvFILL (texture_av) >= 0) |
|
|
2384 | name = (GLuint)(size_t)av_pop (texture_av); |
|
|
2385 | else |
2369 | glGenTextures (1, &name); |
2386 | glGenTextures (1, &name); |
2370 | RETVAL = name; |
2387 | RETVAL = name; |
2371 | } |
2388 | } |
2372 | OUTPUT: |
2389 | OUTPUT: |
2373 | RETVAL |
2390 | RETVAL |
2374 | |
2391 | |
2375 | void glDeleteTexture (int name) |
2392 | void glDeleteTexture (int name) |
2376 | CODE: |
2393 | CODE: |
2377 | { |
2394 | { |
2378 | GLuint name_ = name; |
2395 | /* make a half-assed attempt at returning the memory used by the texture */ |
|
|
2396 | /* textures are frequently being reused by cfplus anyway */ |
|
|
2397 | glBindTexture (GL_TEXTURE_2D, name); |
|
|
2398 | glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, 0, 0, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0); |
|
|
2399 | av_push (texture_av, (SV *)(size_t)name); |
2379 | glDeleteTextures (1, &name_); |
2400 | /*glDeleteTextures (1, &name_);*/ |
2380 | } |
2401 | } |
2381 | |
2402 | |
2382 | int glGenList () |
2403 | int glGenList () |
2383 | CODE: |
2404 | CODE: |
2384 | RETVAL = glGenLists (1); |
2405 | RETVAL = glGenLists (1); |