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.293 by root, Mon Aug 11 23:23:41 2008 UTC vs.
Revision 1.304 by root, Wed Oct 1 05:50:19 2008 UTC

439 439
440inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); } 440inline SV *to_sv (const std::string & v) { return newSVpvn (v.data (), v.size ()); }
441inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); } 441inline SV *to_sv (const treasurelist *v) { return to_sv (v->name); }
442 442
443inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); } 443inline SV *to_sv (UUID v) { return newSVpv (v.c_str (), 0); }
444
445inline SV *to_sv (dynbuf * v)
446{
447 SV *sv = newSV (0);
448
449 sv_upgrade (sv, SVt_PV);
450 SvGROW (sv, v->size () + 1);
451 SvPOK_only (sv);
452 v->linearise (SvPVX (sv));
453 SvCUR_set (sv, v->size ());
454 *SvEND (sv) = 0;
455
456 return sv;
457}
458
459inline SV *to_sv (dynbuf_text * v)
460{
461 SV *sv = to_sv (static_cast<dynbuf *> (v));
462 SvUTF8_on (sv);
463 return sv;
464}
444 465
445inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 466inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; }
446inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 467inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
447inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 468inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
448inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 469inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
605 626
606 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 627 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
607 628
608 const char *argv[] = { 629 const char *argv[] = {
609 settings.argv [0], 630 settings.argv [0],
610 "-e" 631 "-e0"
611 "use EV; use Coro;" // required for bootstrap
612 "cf->bootstrap;" // required for datadir :*>
613 "unshift @INC, cf::datadir ();"
614 "require cf;"
615 }; 632 };
616 633
617 if (perl_parse (perl, xs_init, 2, (char **)argv, environ) 634 if (perl_parse (perl, xs_init, 2, (char **)argv, environ)
618 || perl_run (perl)) 635 || perl_run (perl))
619 { 636 {
620 printf ("unable to initialize perl-interpreter, aborting.\n"); 637 printf ("unable to initialize perl-interpreter, aborting.\n");
621 exit (EXIT_FAILURE); 638 exit (EXIT_FAILURE);
622 } 639 }
623 640
641 eval_pv (
642 "#line 1 'cfperl init'\n"
643 "use EV ();\n"
644 "use Coro ();\n"
645 "cf->bootstrap;\n"
646 "unshift @INC, cf::datadir ();\n"
647 "require cf;\n",
648 0
649 );
650
651 if (SvTRUE (ERRSV))
624 { 652 {
625 dSP; 653 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV));
626 654 exit (EXIT_FAILURE);
627 PUSHMARK (SP);
628 PUTBACK;
629 call_pv ("cf::init", G_DISCARD | G_VOID);
630 } 655 }
631} 656}
632 657
633void cfperl_main () 658void cfperl_main ()
634{ 659{
635 dSP; 660 dSP;
941{ 966{
942 CALL_BEGIN (2); 967 CALL_BEGIN (2);
943 CALL_ARG (book); 968 CALL_ARG (book);
944 CALL_ARG (level); 969 CALL_ARG (level);
945 CALL_CALL ("ext::books::make_book", G_VOID); 970 CALL_CALL ("ext::books::make_book", G_VOID);
946 CALL_END;
947}
948
949void
950cfperl_expand_cfpod (player *pl, std::string &msg)
951{
952 CALL_BEGIN (2);
953 CALL_ARG (pl);
954 CALL_ARG_SV (newSVpvn_utf8 (msg.data (), msg.size ()));
955 CALL_CALL ("cf::player::expand_cfpod", G_SCALAR);
956
957 if (count)
958 {
959 STRLEN len;
960 char *data = SvPVutf8 (TOPs, len);
961 msg.assign (data, len);
962 }
963
964 CALL_END; 971 CALL_END;
965} 972}
966 973
967void 974void
968cfperl_send_msg (client *ns, int color, const char *type, const char *msg) 975cfperl_send_msg (client *ns, int color, const char *type, const char *msg)
1323 const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL) 1330 const_iv (FLAG_CURSED) const_iv (FLAG_DAMNED) const_iv (FLAG_SEE_ANYWHERE) const_iv (FLAG_KNOWN_MAGICAL)
1324 const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL) 1331 const_iv (FLAG_KNOWN_CURSED) const_iv (FLAG_CAN_USE_SKILL) const_iv (FLAG_BEEN_APPLIED) const_iv (FLAG_READY_SCROLL)
1325 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) 1332 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED)
1326 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) 1333 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON)
1327 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) 1334 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON)
1328 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_CLIENT_SENT) const_iv (FLAG_BERSERK) 1335 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK)
1329 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) 1336 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL)
1330 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) 1337 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER)
1331 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) 1338 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE)
1332 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) 1339 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1333 1340
1334 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1341 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED)
1335 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) 1342 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN)
1336 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD) 1343 const_iv (NDI_LT_GREEN) const_iv (NDI_GREY) const_iv (NDI_BROWN) const_iv (NDI_GOLD)
1337 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE) 1344 const_iv (NDI_TAN) const_iv (NDI_MAX_COLOR) const_iv (NDI_COLOR_MASK) const_iv (NDI_UNIQUE)
1338 const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK) 1345 const_iv (NDI_ALL) const_iv (NDI_DEF) const_iv (NDI_REPLY) const_iv (NDI_CLIENT_MASK)
1339 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) 1346 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) const_iv (NDI_VERBATIM)
1340 1347
1341 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) 1348 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE)
1342 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) 1349 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1343 1350
1344 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1351 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE)
1504 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1511 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1505 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1512 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1506 } 1513 }
1507} 1514}
1508 1515
1516void _gv_clear (SV *gv)
1517 CODE:
1518 assert (SvTYPE (gv) == SVt_PVGV);
1519# define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); }
1520 f (GvGP (gv)->gp_form);
1521 f (GvGP (gv)->gp_io);
1522 f (GvGP (gv)->gp_sv);
1523 f (GvGP (gv)->gp_av);
1524 f (GvGP (gv)->gp_hv);
1525 f (GvGP (gv)->gp_cv);
1526 GvCVGEN (gv) = 0;
1527 GvMULTI_off (gv);
1528# undef f
1529
1509void _connect_to_perl () 1530void _connect_to_perl ()
1510 1531
1511void _recalc_want () 1532void _recalc_want ()
1512 1533
1534# not used by default anymore
1513void _global_reattach () 1535void _global_reattach ()
1514 CODE: 1536 CODE:
1515{ 1537{
1516 // reattach to all attachable objects in the game. 1538 // reattach to all attachable objects in the game.
1517 for_all_clients (ns) 1539 for_all_clients (ns)
1560 len -= 3; 1582 len -= 3;
1561 } 1583 }
1562 1584
1563 SvCUR_set (data_sv, dst - SvPVX (data_sv)); 1585 SvCUR_set (data_sv, dst - SvPVX (data_sv));
1564} 1586}
1587
1588void init_anim ()
1589
1590void init_globals ()
1591
1592void init_experience ()
1593
1594void init_attackmess ()
1595
1596void init_dynamic ()
1597
1598void init_block ()
1599
1600void load_settings ()
1601
1602void load_materials ()
1603
1604void init_uuid ()
1605 CODE:
1606 UUID::init ();
1607
1608void init_signals ()
1609
1610void init_commands ()
1611
1612void init_skills ()
1613
1614void init_beforeplay ()
1565 1615
1566void evthread_start (int aiofd) 1616void evthread_start (int aiofd)
1567 1617
1568void cede_to_tick () 1618void cede_to_tick ()
1569 CODE: 1619 CODE:
1707#if _POSIX_MEMLOCK 1757#if _POSIX_MEMLOCK
1708 1758
1709int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1759int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1710 INIT: 1760 INIT:
1711#if __GLIBC__ 1761#if __GLIBC__
1762 mallopt (M_TOP_PAD, 1024 * 1024);
1763 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128);
1764 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1712 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1765 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1713#endif 1766#endif
1714 1767
1715int munlockall () 1768int munlockall ()
1716 1769
2211 pl->failmsg ("[packet too long for client]"); 2264 pl->failmsg ("[packet too long for client]");
2212 else if (pl->ns) 2265 else if (pl->ns)
2213 pl->ns->send_packet (buf, len); 2266 pl->ns->send_packet (buf, len);
2214} 2267}
2215 2268
2216int
2217listening (player *pl, int new_value = -1)
2218 CODE:
2219 RETVAL = pl->listening;
2220 if (new_value >= 0)
2221 pl->listening = new_value;
2222 OUTPUT:
2223 RETVAL
2224
2225void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0) 2269void savebed (player *pl, SV *map_path = 0, SV *x = 0, SV *y = 0)
2226 PROTOTYPE: $;$$$ 2270 PROTOTYPE: $;$$$
2227 PPCODE: 2271 PPCODE:
2228 if (GIMME_V != G_VOID) 2272 if (GIMME_V != G_VOID)
2229 { 2273 {
2383} 2427}
2384 2428
2385void 2429void
2386maptile::create_region_treasure () 2430maptile::create_region_treasure ()
2387 CODE: 2431 CODE:
2388{
2389 object *op = object::create ();
2390 op->type = FLOOR;
2391 op->map = THIS;
2392
2393 for (int x = 0; x < THIS->width; ++x) 2432 for (int x = 0; x < THIS->width; ++x)
2394 for (int y = 0; y < THIS->height; ++y) 2433 for (int y = 0; y < THIS->height; ++y)
2395 { 2434 {
2396 region *rgn = THIS->region (x, y); 2435 region *rgn = THIS->region (x, y);
2397 2436
2398 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D 2437 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2438 if (object *op = THIS->at (x, y).top)
2399 if (rgn->treasure && rndm () < rgn->treasure_density) 2439 if (rgn->treasure && rndm () < rgn->treasure_density)
2400 {
2401 op->x = x;
2402 op->y = y;
2403 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2440 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2404 }
2405 } 2441 }
2406
2407 op->destroy ();
2408}
2409 2442
2410int out_of_map (maptile *map, int x, int y) 2443int out_of_map (maptile *map, int x, int y)
2411 2444
2412void 2445void
2413trigger (maptile *map, long connection, bool state = true) 2446trigger (maptile *map, long connection, bool state = true)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines