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.294 by root, Fri Aug 29 02:07:09 2008 UTC vs.
Revision 1.302 by root, Mon Sep 22 23:57:48 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); }
941{ 962{
942 CALL_BEGIN (2); 963 CALL_BEGIN (2);
943 CALL_ARG (book); 964 CALL_ARG (book);
944 CALL_ARG (level); 965 CALL_ARG (level);
945 CALL_CALL ("ext::books::make_book", G_VOID); 966 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; 967 CALL_END;
965} 968}
966 969
967void 970void
968cfperl_send_msg (client *ns, int color, const char *type, const char *msg) 971cfperl_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) 1326 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) 1327 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) 1328 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) 1329 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) 1330 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) 1331 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) 1332 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) 1333 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) 1334 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) 1335 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1333 1336
1334 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1337 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) 1338 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) 1339 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) 1340 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) 1341 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) 1342 const_iv (NDI_NOCREATE) const_iv (NDI_CLEAR) const_iv (NDI_VERBATIM)
1340 1343
1341 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) 1344 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) 1345 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1343 1346
1344 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1347 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)); 1507 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1505 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1508 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1506 } 1509 }
1507} 1510}
1508 1511
1512void _gv_clear (SV *gv)
1513 CODE:
1514 assert (SvTYPE (gv) == SVt_PVGV);
1515# define f(sv) { SV *sv_ = (SV *)(sv); sv = 0; SvREFCNT_dec (sv_); }
1516 f (GvGP (gv)->gp_form);
1517 f (GvGP (gv)->gp_io);
1518 f (GvGP (gv)->gp_sv);
1519 f (GvGP (gv)->gp_av);
1520 f (GvGP (gv)->gp_hv);
1521 f (GvGP (gv)->gp_cv);
1522 GvCVGEN (gv) = 0;
1523 GvMULTI_off (gv);
1524# undef f
1525
1526
1509void _connect_to_perl () 1527void _connect_to_perl ()
1510 1528
1511void _recalc_want () 1529void _recalc_want ()
1512 1530
1513void _global_reattach () 1531void _global_reattach ()
1707#if _POSIX_MEMLOCK 1725#if _POSIX_MEMLOCK
1708 1726
1709int mlockall (int flags = MCL_CURRENT | MCL_FUTURE) 1727int mlockall (int flags = MCL_CURRENT | MCL_FUTURE)
1710 INIT: 1728 INIT:
1711#if __GLIBC__ 1729#if __GLIBC__
1730 mallopt (M_TOP_PAD, 1024 * 1024);
1731 mallopt (M_MMAP_THRESHOLD, 1024 * 1024 * 128);
1732 mallopt (M_MMAP_MAX, 0); // likely bug-workaround, also frees memory
1712 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc 1733 mallopt (M_PERTURB, 0xee); // bug-workaround for linux glibc+mlockall+calloc
1713#endif 1734#endif
1714 1735
1715int munlockall () 1736int munlockall ()
1716 1737
2374} 2395}
2375 2396
2376void 2397void
2377maptile::create_region_treasure () 2398maptile::create_region_treasure ()
2378 CODE: 2399 CODE:
2379{
2380 object *op = object::create ();
2381 op->type = FLOOR;
2382 op->map = THIS;
2383
2384 for (int x = 0; x < THIS->width; ++x) 2400 for (int x = 0; x < THIS->width; ++x)
2385 for (int y = 0; y < THIS->height; ++y) 2401 for (int y = 0; y < THIS->height; ++y)
2386 { 2402 {
2387 region *rgn = THIS->region (x, y); 2403 region *rgn = THIS->region (x, y);
2388 2404
2389 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D 2405 //fprintf (stderr, "%d,%d %f %p\n", x, y, rgn->treasure_density,rgn->treasure);//D
2406 if (object *op = THIS->at (x, y).top)
2390 if (rgn->treasure && rndm () < rgn->treasure_density) 2407 if (rgn->treasure && rndm () < rgn->treasure_density)
2391 {
2392 op->x = x;
2393 op->y = y;
2394 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty); 2408 create_treasure (rgn->treasure, op, GT_ENVIRONMENT, THIS->difficulty);
2395 }
2396 } 2409 }
2397
2398 op->destroy ();
2399}
2400 2410
2401int out_of_map (maptile *map, int x, int y) 2411int out_of_map (maptile *map, int x, int y)
2402 2412
2403void 2413void
2404trigger (maptile *map, long connection, bool state = true) 2414trigger (maptile *map, long connection, bool state = true)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines