ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.391 by root, Sat Jul 3 01:49:18 2010 UTC vs.
Revision 1.399 by root, Fri Apr 22 02:03:12 2011 UTC

28 28
29#include <cstdarg> 29#include <cstdarg>
30#include <typeinfo> 30#include <typeinfo>
31 31
32#include "global.h" 32#include "global.h"
33#include "../random_maps/random_map.h" 33#include "rmg.h"
34#include "evthread.h" 34#include "evthread.h"
35#include "sproto.h" 35#include "sproto.h"
36 36
37#include <unistd.h> 37#include <unistd.h>
38#if _POSIX_MEMLOCK 38#if _POSIX_MEMLOCK
1459# include "attackinc.h" 1459# include "attackinc.h"
1460# undef def 1460# undef def
1461# define def(uc, flags) const_iv (SK_ ## uc) 1461# define def(uc, flags) const_iv (SK_ ## uc)
1462# include "skillinc.h" 1462# include "skillinc.h"
1463# undef def 1463# undef def
1464 1464# define def(name, use, nonuse) const_iv (body_ ## name)
1465 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1465# include "slotinc.h"
1466# undef def
1466 1467
1467 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1468 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1468 1469
1469 const_iv (MAX_TIME) 1470 const_iv (MAX_TIME)
1470 const_iv (MAXSOCKBUF) 1471 const_iv (MAXSOCKBUF)
1554 for_all_clients (ns) 1555 for_all_clients (ns)
1555 ns->reattach (); 1556 ns->reattach ();
1556 1557
1557 for_all_objects (op) 1558 for_all_objects (op)
1558 op->reattach (); 1559 op->reattach ();
1559}
1560
1561# support function for map-world.ext
1562void _quantise (SV *data_sv, SV *plt_sv)
1563 CODE:
1564{
1565 if (!SvROK (plt_sv) || SvTYPE (SvRV (plt_sv)) != SVt_PVAV)
1566 croak ("_quantise called with invalid agruments");
1567
1568 plt_sv = SvRV (plt_sv);
1569 SV **plt = AvARRAY (plt_sv);
1570 int plt_count = AvFILL (plt_sv) + 1;
1571
1572 STRLEN len;
1573 char *data = SvPVbyte (data_sv, len);
1574 char *dst = data;
1575
1576 while (len >= 3)
1577 {
1578 for (SV **val_sv = plt + plt_count; val_sv-- > plt; )
1579 {
1580 char *val = SvPVX (*val_sv);
1581
1582 if (val [0] == data [0]
1583 && val [1] == data [1]
1584 && val [2] == data [2])
1585 {
1586 *dst++ = val [3];
1587 goto next;
1588 }
1589 }
1590
1591 croak ("_quantise: color not found in palette: #%02x%02x%02x, at offset %d %d",
1592 (uint8_t)data [0], (uint8_t)data [1], (uint8_t)data [2],
1593 dst - SvPVX (data_sv), len);
1594
1595 next:
1596 data += 3;
1597 len -= 3;
1598 }
1599
1600 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1601} 1560}
1602 1561
1603void init_anim () 1562void init_anim ()
1604 1563
1605void init_globals () 1564void init_globals ()
1775 1734
1776int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1735int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1777 INIT: 1736 INIT:
1778#if __GLIBC__ 1737#if __GLIBC__
1779 mallopt (M_TOP_PAD, 1024 * 1024); 1738 mallopt (M_TOP_PAD, 1024 * 1024);
1780 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128); 1739 mallopt (M_MMAP_THRESHOLD, 1024 * 1024);
1781 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory 1740 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1741 if (__GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 10))
1782 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1742 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1783#endif 1743#endif
1784 1744
1785int munlockall () 1745int munlockall ()
1786 1746
1787#endif 1747#endif
1825int exp_to_level (val64 exp) 1785int exp_to_level (val64 exp)
1826 1786
1827val64 level_to_min_exp (int level) 1787val64 level_to_min_exp (int level)
1828 1788
1829SV * 1789SV *
1830resistance_to_string (int atnr) 1790attacktype_name (int atnr)
1831 CODE: 1791 CODE:
1832 if (atnr >= 0 && atnr < NROFATTACKS) 1792 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1793 ? newSVpv (attacktype_name [atnr], 0)
1794 : &PL_sv_undef;
1795 OUTPUT: RETVAL
1796
1797SV *
1798attacktype_desc (int atnr)
1799 CODE:
1800 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1801 ? newSVpv (attacktype_desc [atnr], 0)
1802 : &PL_sv_undef;
1803 OUTPUT: RETVAL
1804
1805SV *
1806resist_plus (int atnr)
1807 CODE:
1808 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1833 RETVAL = newSVpv (resist_plus[atnr], 0); 1809 ? newSVpv (resist_plus [atnr], 0)
1834 else 1810 : &PL_sv_undef;
1835 XSRETURN_UNDEF; 1811 OUTPUT: RETVAL
1812
1813SV *
1814change_resist_msg (int atnr)
1815 CODE:
1816 RETVAL = IN_RANGE_EXC (atnr, 0, NROFATTACKS)
1817 ? newSVpv (change_resist_msg [atnr], 0)
1818 : &PL_sv_undef;
1836 OUTPUT: RETVAL 1819 OUTPUT: RETVAL
1837 1820
1838UUID 1821UUID
1839uuid_cur () 1822uuid_cur ()
1840 CODE: 1823 CODE:
1963int mortals_size () 1946int mortals_size ()
1964 CODE: 1947 CODE:
1965 RETVAL = attachable::mortals.size (); 1948 RETVAL = attachable::mortals.size ();
1966 OUTPUT: RETVAL 1949 OUTPUT: RETVAL
1967 1950
1968const_utf8_string slot_use_name (U32 slot) 1951const_utf8_string slot_name (U32 slot)
1969 ALIAS: 1952 ALIAS:
1953 slot_name = 0
1954 slot_use_name = 1
1970 slot_nonuse_name = 1 1955 slot_nonuse_name = 2
1971 CODE: 1956 CODE:
1972{ 1957{
1973 if (slot >= NUM_BODY_LOCATIONS) 1958 if (slot >= NUM_BODY_LOCATIONS)
1974 croak ("body slot index out of range"); 1959 croak ("body slot index out of range");
1975 1960
1976 switch (ix) 1961 switch (ix)
1977 { 1962 {
1963 case 0: RETVAL = body_locations[slot].name ; break;
1978 case 0: RETVAL = body_locations[slot].use_name; break; 1964 case 1: RETVAL = body_locations[slot].use_name ; break;
1979 case 1: RETVAL = body_locations[slot].nonuse_name; break; 1965 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1980 } 1966 }
1981} 1967}
1982 OUTPUT: 1968 OUTPUT:
1983 RETVAL 1969 RETVAL
1984 1970
2449 for (int x = 0; x < THIS->width; ++x) 2435 for (int x = 0; x < THIS->width; ++x)
2450 for (int y = 0; y < THIS->height; ++y) 2436 for (int y = 0; y < THIS->height; ++y)
2451 { 2437 {
2452 region *rgn = THIS->region (x, y); 2438 region *rgn = THIS->region (x, y);
2453 2439
2454 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2455 if (object *op = THIS->at (x, y).top) 2440 if (object *op = THIS->at (x, y).top)
2456 if (rgn->treasure && rndm () < rgn->treasure_density) 2441 if (rgn->treasure && rndm () < rgn->treasure_density)
2457 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2442 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2458 } 2443 }
2459 2444
2723 2708
2724void set_data (faceidx idx, int faceset, SV *data, SV *chksum) 2709void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2725 CODE: 2710 CODE:
2726{ 2711{
2727 faceinfo *f = face_info (idx); assert (f); 2712 faceinfo *f = face_info (idx); assert (f);
2728 facedata *d = &(faceset ? f->data64 : f->data32); 2713 facedata *d = f->face + faceset;
2729 sv_to (data, d->data); 2714 sv_to (data, d->data);
2730 STRLEN clen; 2715 STRLEN clen;
2731 char *cdata = SvPVbyte (chksum, clen); 2716 char *cdata = SvPVbyte (chksum, clen);
2732 clen = min (CHKSUM_MAXLEN, clen); 2717 clen = min (CHKSUM_MAXLEN, clen);
2733 2718
2887 self->skip (); 2872 self->skip ();
2888 } 2873 }
2889 2874
2890MODULE = cf PACKAGE = cf::layout 2875MODULE = cf PACKAGE = cf::layout
2891 2876
2892INCLUDE: $PERL $srcdir/genacc layout $srcdir/../random_maps/random_map.h | 2877INCLUDE: $PERL $srcdir/genacc layout $srcdir/../include/rmg.h |
2893 2878

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines