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.174 by root, Tue Mar 6 03:06:00 2007 UTC vs.
Revision 1.181 by root, Tue Apr 3 00:21:38 2007 UTC

349inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); } 349inline SV *to_sv (living * v) { return newSVptr (v, stash_cf_living_wrap); }
350 350
351inline SV *to_sv (object & v) { return to_sv (&v); } 351inline SV *to_sv (object & v) { return to_sv (&v); }
352inline SV *to_sv (living & v) { return to_sv (&v); } 352inline SV *to_sv (living & v) { return to_sv (&v); }
353 353
354inline SV *to_sv (facetile * v) { return to_sv (v->name); } 354//inline SV *to_sv (faceinfo * v) { return to_sv (v->name); }
355inline SV *to_sv (treasurelist * v) { return to_sv (v->name); } 355inline SV *to_sv (treasurelist * v) { return to_sv (v->name); }
356inline SV *to_sv (std::string & v) { return newSVpvn (v.data (), v.size ()); }
356 357
357inline SV *to_sv (UUID v) 358inline SV *to_sv (UUID v)
358{ 359{
359 char buf[128]; 360 char buf[128];
360 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq); 361 snprintf (buf, 128, "<1.%" PRIx64 ">", v.seq);
384inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); } 385inline void sv_to (SV *sv, attachable * &v) { v = (attachable *)SvPTR_ornull (sv, "cf::attachable"); }
385inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 386inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
386inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 387inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
387inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 388inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
388 389
389inline void sv_to (SV *sv, facetile * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } 390//inline void sv_to (SV *sv, faceinfo * &v) { v = &faces [face_find (SvPV_nolen (sv), 0)]; }
390inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } 391inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); }
391 392
392template<class T> 393template<class T>
393inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } 394inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
394 395
398inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } 399inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); }
399inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } 400inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); }
400inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } 401inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); }
401inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } 402inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); }
402inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } 403inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); }
404
405inline void sv_to (SV *sv, std::string &v)
406{
407 STRLEN len;
408 char *data = SvPVbyte (sv, len);
409 v.assign (data, len);
410}
403 411
404inline void sv_to (SV *sv, UUID &v) 412inline void sv_to (SV *sv, UUID &v)
405{ 413{
406 unsigned int version; 414 unsigned int version;
407 415
598 perl = perl_alloc (); 606 perl = perl_alloc ();
599 perl_construct (perl); 607 perl_construct (perl);
600 608
601 PL_exit_flags |= PERL_EXIT_DESTRUCT_END; 609 PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
602 610
603 char *argv[] = { 611 const char *argv[] = {
604 "", 612 "",
605 "-e" 613 "-e"
606 "use Event; use Coro;" // required for bootstrap 614 "use Event; use Coro;" // required for bootstrap
607 "cf->bootstrap;" // required for datadir :*> 615 "cf->bootstrap;" // required for datadir :*>
608 "unshift @INC, cf::datadir ();" 616 "unshift @INC, cf::datadir ();"
609 "require cf;" 617 "require cf;"
610 }; 618 };
611 619
612 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) 620 if (perl_parse (perl, xs_init, 2, (char **)argv, (char **)NULL)
621 || perl_run (perl))
613 { 622 {
614 printf ("unable to initialize perl-interpreter, aborting.\n"); 623 printf ("unable to initialize perl-interpreter, aborting.\n");
615 exit (EXIT_FAILURE); 624 exit (EXIT_FAILURE);
616 } 625 }
617 626
1042# define const_iv(name) { # name, (IV)name }, 1051# define const_iv(name) { # name, (IV)name },
1043 const_iv (llevError) 1052 const_iv (llevError)
1044 const_iv (llevInfo) 1053 const_iv (llevInfo)
1045 const_iv (llevDebug) 1054 const_iv (llevDebug)
1046 const_iv (llevMonster) 1055 const_iv (llevMonster)
1056
1057 const_iv (Map0Cmd)
1058 const_iv (Map1Cmd)
1059 const_iv (Map1aCmd)
1060
1061 const_iv (MAP_CLIENT_X)
1062 const_iv (MAP_CLIENT_Y)
1047 1063
1048 const_iv (MAX_TIME) 1064 const_iv (MAX_TIME)
1049 const_iv (PLAYER) 1065 const_iv (PLAYER)
1050 const_iv (TRANSPORT) 1066 const_iv (TRANSPORT)
1051 const_iv (ROD) 1067 const_iv (ROD)
1635void 1651void
1636sub_generation_inc () 1652sub_generation_inc ()
1637 CODE: 1653 CODE:
1638 PL_sub_generation++; 1654 PL_sub_generation++;
1639 1655
1640char * 1656const char *
1641mapdir () 1657mapdir ()
1642 PROTOTYPE: 1658 PROTOTYPE:
1643 ALIAS: 1659 ALIAS:
1644 mapdir = 0 1660 mapdir = 0
1645 uniquedir = 1 1661 uniquedir = 1
2061void clear_los (object *op) 2077void clear_los (object *op)
2062 2078
2063int command_summon (object *op, char *params) 2079int command_summon (object *op, char *params)
2064 2080
2065int command_arrest (object *op, char *params) 2081int command_arrest (object *op, char *params)
2066
2067int command_banish (object *op, char *params)
2068 2082
2069 2083
2070MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ 2084MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
2071 2085
2072INCLUDE: $PERL $srcdir/genacc player ../include/player.h | 2086INCLUDE: $PERL $srcdir/genacc player ../include/player.h |
2508 char *buf = SvPVbyte (packet, len); 2522 char *buf = SvPVbyte (packet, len);
2509 2523
2510 THIS->send_packet (buf, len); 2524 THIS->send_packet (buf, len);
2511} 2525}
2512 2526
2527MODULE = cf PACKAGE = cf::face PREFIX = face_
2528
2529INCLUDE: $PERL $srcdir/genacc faceset ../include/face.h |
2530
2531faceidx face_find (const char *name, faceidx defidx = 0)
2532
2533faceidx alloc (const char *name)
2534 CODE:
2535{
2536 do
2537 {
2538 RETVAL = faces.size ();
2539 faces.resize (RETVAL + 1);
2540 }
2541 while (!RETVAL); // crude way to leave index 0
2542
2543 faces [RETVAL].name = name;
2544 facehash.insert (std::make_pair (faces [RETVAL].name, RETVAL));
2545
2546 if (!strcmp (name, BLANK_FACE_NAME)) blank_face = RETVAL;
2547 if (!strcmp (name, EMPTY_FACE_NAME)) empty_face = RETVAL;
2548}
2549 OUTPUT: RETVAL
2550
2551void set (faceidx idx, int visibility, int magicmap)
2552 CODE:
2553 faceinfo *f = face_info (idx);
2554 assert (f);
2555 f->visibility = visibility;
2556 f->magicmap = magicmap;
2557
2558void set_smooth (faceidx idx, faceidx smooth)
2559 CODE:
2560 faceinfo *f = face_info (idx);
2561 assert (f);
2562 f->smooth = smooth;
2563
2564void set_data (faceidx idx, int faceset, SV *data, SV *chksum)
2565 CODE:
2566 facedata *d = face_data (idx, faceset);
2567 assert (d);
2568 sv_to (data, d->data);
2569 STRLEN clen;
2570 char *cdata = SvPVbyte (chksum, clen);
2571 memcpy (d->chksum, cdata, min (CHKSUM_SIZE, clen));
2572
2573void invalidate (faceidx idx)
2574 CODE:
2575 for_all_clients (ns)
2576 ns->faces_sent [idx] = false;
2577
2578void invalidate_all ()
2579 CODE:
2580 for_all_clients (ns)
2581 ns->faces_sent.reset ();
2582

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines