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.95 by elmex, Wed Dec 20 14:38:50 2006 UTC vs.
Revision 1.96 by root, Thu Dec 21 06:12:37 2006 UTC

59static f_plug_api object_set_property = cfapi_object_set_property; 59static f_plug_api object_set_property = cfapi_object_set_property;
60static f_plug_api object_insert = cfapi_object_insert; 60static f_plug_api object_insert = cfapi_object_insert;
61 61
62static PerlInterpreter *perl; 62static PerlInterpreter *perl;
63 63
64static AV *cb_global, *cb_object, *cb_player, *cb_type, *cb_map; 64static AV *cb_global, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
65 65
66////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 66//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67 67
68static SV * 68static SV *
69newSVptr (void *ptr, const char *klass, HV *hv = newHV ()) 69newSVptr (void *ptr, const char *klass, HV *hv = newHV ())
412 412
413 switch (type) 413 switch (type)
414 { 414 {
415 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break; 415 case DT_OBJECT: INVOKE_OBJECT (REATTACH, obj); break;
416 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break; 416 case DT_PLAYER: INVOKE_PLAYER (REATTACH, obj); break;
417 case DT_CLIENT: INVOKE_CLIENT (REATTACH, obj); break;
417 case DT_MAP: INVOKE_MAP (REATTACH, obj); break; 418 case DT_MAP: INVOKE_MAP (REATTACH, obj); break;
418 } 419 }
419} 420}
420 421
421template<class subclass> 422template<class subclass>
906 AV *callbacks = 0; 907 AV *callbacks = 0;
907 908
908 object *op; 909 object *op;
909 player *pl; 910 player *pl;
910 maptile *map; 911 maptile *map;
912 client *ns;
911 913
912 // callback call ordering is: 914 // callback call ordering is:
913 // 1. per-object callback 915 // 1. per-object callback
914 // 2. per-class object 916 // 2. per-class object
915 // 3. per-type callback 917 // 3. per-type callback
973 gather_callbacks (callbacks, map->cb, event); 975 gather_callbacks (callbacks, map->cb, event);
974 976
975 gather_callbacks (callbacks, cb_map, event); 977 gather_callbacks (callbacks, cb_map, event);
976 break; 978 break;
977 979
980 case KLASS_CLIENT:
981 dt = (data_type) va_arg (ap, int);
982 assert (("first argument must be of type client", dt == DT_CLIENT));
983 ns = va_arg (ap, client *);
984
985 if (ns->cb)
986 gather_callbacks (callbacks, ns->cb, event);
987
988 gather_callbacks (callbacks, cb_client, event);
989 break;
990
978 default: 991 default:
979 assert (("unsupported event klass in cfperl_invoke", 0)); 992 assert (("unsupported event klass in cfperl_invoke", 0));
980 } 993 }
981 994
982 // short-circuit processing if no callbacks found/defined 995 // short-circuit processing if no callbacks found/defined
995 1008
996 switch (KLASS_OF (event)) 1009 switch (KLASS_OF (event))
997 { 1010 {
998 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break; 1011 case KLASS_OBJECT: PUSHs (sv_2mortal (newSVdt (DT_OBJECT, op))); break;
999 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break; 1012 case KLASS_PLAYER: PUSHs (sv_2mortal (newSVdt (DT_PLAYER, pl))); break;
1013 case KLASS_CLIENT: PUSHs (sv_2mortal (newSVdt (DT_CLIENT, pl))); break;
1000 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break; 1014 case KLASS_MAP: PUSHs (sv_2mortal (newSVdt (DT_MAP, map))); break;
1001 } 1015 }
1002 1016
1003 for (;;) 1017 for (;;)
1004 { 1018 {
1604 const_iv (MAP_LOADING) 1618 const_iv (MAP_LOADING)
1605 const_iv (MAP_SAVING) 1619 const_iv (MAP_SAVING)
1606 1620
1607 const_iv (KLASS_GLOBAL) 1621 const_iv (KLASS_GLOBAL)
1608 const_iv (KLASS_OBJECT) 1622 const_iv (KLASS_OBJECT)
1623 const_iv (KLASS_CLIENT)
1609 const_iv (KLASS_PLAYER) 1624 const_iv (KLASS_PLAYER)
1610 const_iv (KLASS_MAP) 1625 const_iv (KLASS_MAP)
1611 }; 1626 };
1612 1627
1613 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 1628 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
1639void _init_vars () 1654void _init_vars ()
1640 CODE: 1655 CODE:
1641 cb_global = get_av ("cf::CB_GLOBAL", 1); 1656 cb_global = get_av ("cf::CB_GLOBAL", 1);
1642 cb_object = get_av ("cf::CB_OBJECT", 1); 1657 cb_object = get_av ("cf::CB_OBJECT", 1);
1643 cb_player = get_av ("cf::CB_PLAYER", 1); 1658 cb_player = get_av ("cf::CB_PLAYER", 1);
1659 cb_client = get_av ("cf::CB_CLIENT", 1);
1644 cb_type = get_av ("cf::CB_TYPE" , 1); 1660 cb_type = get_av ("cf::CB_TYPE" , 1);
1645 cb_map = get_av ("cf::CB_MAP" , 1); 1661 cb_map = get_av ("cf::CB_MAP" , 1);
1646 1662
1647void _global_reattach () 1663void _global_reattach ()
1648 CODE: 1664 CODE:
1649{ 1665{
1650 // reattach to all attachable objects in the game. 1666 // reattach to all attachable objects in the game.
1667 for (sockvec::iterator i = clients.begin (); i != clients.end (); ++i)
1668 reattach (*i);
1669
1651 for (player *pl = first_player; pl; pl = pl->next) 1670 for (player *pl = first_player; pl; pl = pl->next)
1652 reattach (pl); 1671 reattach (pl);
1653 1672
1654 for (maptile *map = first_map; map; map = map->next) 1673 for (maptile *map = first_map; map; map = map->next)
1655 reattach (map); 1674 reattach (map);
1656 1675
1657 for (object *op = object::first; op; op = op->next) 1676 for (object *op = object::first; op; op = op->next)
1658 reattach (op); 1677 reattach (op);
1659} 1678}
1660
1661bool
1662add_client (int fd, const char *peername)
1663 1679
1664NV floor (NV x) 1680NV floor (NV x)
1665 1681
1666NV ceil (NV x) 1682NV ceil (NV x)
1667 1683
2436 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av)); 2452 RETVAL = INVOKE_((event_type)event, ARG_CLIENT (ns), ARG_AV (av));
2437 OUTPUT: RETVAL 2453 OUTPUT: RETVAL
2438 2454
2439SV *registry (client *ns) 2455SV *registry (client *ns)
2440 2456
2457client *
2458create (int fd, const char *peername)
2459 CODE:
2460 RETVAL = client::create (fd, peername);
2461 OUTPUT:
2462 RETVAL
2463
2441void 2464void
2442client::destroy () 2465client::destroy ()
2443 2466

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines