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.72 by root, Mon Dec 11 21:39:48 2006 UTC vs.
Revision 1.73 by root, Mon Dec 11 22:56:57 2006 UTC

771static CommArray_s rtn_cmd; 771static CommArray_s rtn_cmd;
772 772
773static int 773static int
774runPluginCommand (object *obj, char *params) 774runPluginCommand (object *obj, char *params)
775{ 775{
776 dSP; 776 return -1;
777
778 ENTER;
779 SAVETMPS;
780
781 PUSHMARK (SP);
782
783 EXTEND (SP, 3);
784 PUSHs (sv_2mortal (newSVpv (rtn_cmd.name, 0)));
785 PUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, obj)));
786
787 if (params)
788 PUSHs (sv_2mortal (newSVpv (params, 0)));
789
790 PUTBACK;
791 int count = call_pv ("cf::inject_command", G_SCALAR | G_EVAL);
792 SPAGAIN;
793
794 if (SvTRUE (ERRSV))
795 LOG (llevError, "command '%s' callback evaluation error: %s", rtn_cmd.name, SvPV_nolen (ERRSV));
796
797 int returnvalue = count > 0 ? POPi : -1;
798
799 PUTBACK;
800 FREETMPS;
801 LEAVE;
802
803 return returnvalue;
804} 777}
805 778
806extern "C" void *cfperl_getPluginProperty (int *type, ...) 779extern "C" void *cfperl_getPluginProperty (int *type, ...)
807{ 780{
808 va_list args; 781 va_list args;
811 va_start (args, type); 784 va_start (args, type);
812 propname = va_arg (args, char *); 785 propname = va_arg (args, char *);
813 //printf ("Property name: %s\n", propname); 786 //printf ("Property name: %s\n", propname);
814 787
815 if (!strcmp (propname, "command?")) 788 if (!strcmp (propname, "command?"))
816 {
817 if (!perl)
818 return NULL; 789 return NULL;
819 790 else if (!strcmp (propname, "Identification"))
820 const char *cmdname = va_arg (args, const char *); 791 {
821 HV *hv = get_hv ("cf::COMMAND", 1);
822 SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0);
823
824 va_end (args); 792 va_end (args);
825 793 return (void *)PLUGIN_NAME;
826 if (svp)
827 {
828 // this is totaly broken, should stash it into %COMMAND
829 rtn_cmd.name = cmdname;
830 rtn_cmd.time = SvNV (*svp);
831 rtn_cmd.func = runPluginCommand;
832
833 return &rtn_cmd;
834 }
835 } 794 }
836 else if (!strcmp (propname, "Identification")) 795 else if (!strcmp (propname, "FullName"))
837 { 796 {
838 va_end (args); 797 va_end (args);
839 return (void*) PLUGIN_NAME;
840 }
841 else if (!strcmp (propname, "FullName"))
842 {
843 va_end (args);
844 return (void*) PLUGIN_VERSION; 798 return (void *)PLUGIN_VERSION;
845 } 799 }
846 else 800 else
847 va_end (args); 801 va_end (args);
848 802
849 return NULL; 803 return NULL;
947 object *op; 901 object *op;
948 player *pl; 902 player *pl;
949 maptile *map; 903 maptile *map;
950 904
951 // callback call ordering is: 905 // callback call ordering is:
952 // 1. per-object callback (NYI) 906 // 1. per-object callback
953 // 2. per-class object 907 // 2. per-class object
954 // 2a. per-type callback 908 // 3. per-type callback
955 // 4. global callbacks 909 // 4. global callbacks
956 910
957 gather_callbacks (callbacks, cb_global, event); 911 gather_callbacks (callbacks, cb_global, event);
958 912
959 switch (KLASS_OF (event)) 913 switch (KLASS_OF (event))
1087 1041
1088int 1042int
1089cfperl_result_INT (int idx) 1043cfperl_result_INT (int idx)
1090{ 1044{
1091 return SvIV (cfperl_result (idx)); 1045 return SvIV (cfperl_result (idx));
1046}
1047
1048int
1049cfperl_result_DOUBLE (int idx)
1050{
1051 return SvNV (cfperl_result (idx));
1092} 1052}
1093 1053
1094MODULE = cf PACKAGE = cf PREFIX = cf_ 1054MODULE = cf PACKAGE = cf PREFIX = cf_
1095 1055
1096BOOT: 1056BOOT:
1620 //I_EVENT_API (PACKAGE); 1580 //I_EVENT_API (PACKAGE);
1621} 1581}
1622 1582
1623void _init_vars () 1583void _init_vars ()
1624 CODE: 1584 CODE:
1625 cb_global = get_av ("cf::CB_GLOBAL", 1); 1585 cb_global = get_av ("cf::CB_GLOBAL", 1);
1626 cb_object = get_av ("cf::CB_OBJECT", 1); 1586 cb_object = get_av ("cf::CB_OBJECT", 1);
1627 cb_player = get_av ("cf::CB_PLAYER", 1); 1587 cb_player = get_av ("cf::CB_PLAYER", 1);
1628 cb_type = get_av ("cf::CB_TYPE" , 1); 1588 cb_type = get_av ("cf::CB_TYPE" , 1);
1629 cb_map = get_av ("cf::CB_MAP" , 1); 1589 cb_map = get_av ("cf::CB_MAP" , 1);
1630 1590
1631void _global_reattach () 1591void _global_reattach ()
1632 CODE: 1592 CODE:
1633{ 1593{
1634 // reattach to all attachable objects in the game. 1594 // reattach to all attachable objects in the game.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines