ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/cfperl/cfperl.xs
(Generate patch)

Comparing deliantra/server/plugins/cfperl/cfperl.xs (file contents):
Revision 1.1 by root, Fri Feb 3 07:25:25 2006 UTC vs.
Revision 1.12 by root, Tue Feb 7 03:01:29 2006 UTC

1/*****************************************************************************/ 1/*****************************************************************************/
2/* That code is placed under the GNU General Public Licence (GPL) */
3/* (C)2001-2005 by Chachkoff Yann (Feel free to deliver your complaints) */
4/*****************************************************************************/
5/* CrossFire, A Multiplayer game for X-windows */ 2/* CrossFire, A Multiplayer game for the X Window System */
6/* */
7/* Copyright (C) 2000 Mark Wedel */
8/* Copyright (C) 1992 Frank Tore Johansen */
9/* Copyright (C) 2006 perl plugin by Marc Lehmann <cf@schmorpd.e> */
10/* */
11/* This program is free software; you can redistribute it and/or modify */
12/* it under the terms of the GNU General Public License as published by */
13/* the Free Software Foundation; either version 2 of the License, or */
14/* (at your option) any later version. */
15/* */
16/* This program is distributed in the hope that it will be useful, */
17/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
18/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
19/* GNU General Public License for more details. */
20/* */
21/* You should have received a copy of the GNU General Public License */
22/* along with this program; if not, write to the Free Software */
23/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
24/* */ 3/* */
25/*****************************************************************************/ 4/*****************************************************************************/
5
6/*
7 * This code is placed under the GNU General Public Licence (GPL)
8 *
9 * Copyright (C) 2001-2005 by Chachkoff Yann
10 * Copyright (C) 2006 by Marc Lehmann <cf@schmorpd.e>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25*/
26 26
27#include <EXTERN.h> 27#include <EXTERN.h>
28#include <perl.h> 28#include <perl.h>
29#include <XSUB.h> 29#include <XSUB.h>
30 30
51 51
52static f_plug_api gethook; 52static f_plug_api gethook;
53static f_plug_api registerGlobalEvent; 53static f_plug_api registerGlobalEvent;
54static f_plug_api unregisterGlobalEvent; 54static f_plug_api unregisterGlobalEvent;
55static f_plug_api systemDirectory; 55static f_plug_api systemDirectory;
56static f_plug_api object_set_property;
56static f_plug_api reCmp; 57static f_plug_api map_get_map;
57 58
58typedef struct 59typedef struct
59{ 60{
60 object* who; 61 object* who;
61 object* activator; 62 object* activator;
129 case CFAPI_DOUBLE: 130 case CFAPI_DOUBLE:
130 sv = newSViv (*va_arg (args, double *)); 131 sv = newSViv (*va_arg (args, double *));
131 break; 132 break;
132 133
133 case CFAPI_STRING: 134 case CFAPI_STRING:
134 sv = newSVpv (va_arg (args, char *), 0); 135 {
136 char *str = va_arg (args, char *);
137 sv = str ? newSVpv (str, 0) : &PL_sv_undef;
138 }
135 break; 139 break;
136 140
137 case CFAPI_POBJECT: 141 case CFAPI_POBJECT:
138 { 142 {
139 object *obj = va_arg (args, object *); 143 object *obj = va_arg (args, object *);
157 } 161 }
158 } 162 }
159 break; 163 break;
160 164
161 case CFAPI_PMAP: 165 case CFAPI_PMAP:
162 sv = newSVptr (va_arg (args, object *), "cf::map"); 166 sv = newSVptr (va_arg (args, mapstruct *), "cf::map");
163 break; 167 break;
164 168
165 case CFAPI_PPLAYER: 169 case CFAPI_PPLAYER:
166 sv = newSVptr (va_arg (args, object *), "cf::player"); 170 sv = newSVptr (va_arg (args, player *), "cf::player");
167 break; 171 break;
168 172
169 case CFAPI_PARCH: 173 case CFAPI_PARCH:
170 sv = newSVptr (va_arg (args, object *), "cf::arch"); 174 sv = newSVptr (va_arg (args, archetype *), "cf::arch");
171 break; 175 break;
172 176
173 case CFAPI_PPARTY: 177 case CFAPI_PPARTY:
174 sv = newSVptr (va_arg (args, object *), "cf::party"); 178 sv = newSVptr (va_arg (args, partylist *), "cf::party");
175 break; 179 break;
176 180
177 case CFAPI_PREGION: 181 case CFAPI_PREGION:
178 sv = newSVptr (va_arg (args, object *), "cf::region"); 182 sv = newSVptr (va_arg (args, region *), "cf::region");
179 break; 183 break;
180 184
181 default: 185 default:
182 assert (("unhandled type in newSVcfapi", 0)); 186 assert (("unhandled type in newSVcfapi", 0));
183 } 187 }
216 220
217 PUTBACK; 221 PUTBACK;
218 int count = call_pv ("cf::inject_event", G_SCALAR | G_EVAL); 222 int count = call_pv ("cf::inject_event", G_SCALAR | G_EVAL);
219 SPAGAIN; 223 SPAGAIN;
220 224
225 if (SvTRUE (ERRSV))
226 LOG (llevError, "event '%d' callback evaluation error: %s", context->event_code, SvPV_nolen (ERRSV));
227
221 context->returnvalue = count > 0 ? POPi : 0; 228 context->returnvalue = count > 0 ? POPi : 0;
222 229
223 PUTBACK; 230 PUTBACK;
224 FREETMPS; 231 FREETMPS;
225 LEAVE; 232 LEAVE;
226
227 if (SvTRUE (ERRSV))
228 LOG (llevError, "event '%d' callback evaluation error: %s", context->event_code, SvPV_nolen (ERRSV));
229} 233}
230 234
231///////////////////////////////////////////////////////////////////////////// 235/////////////////////////////////////////////////////////////////////////////
232 236
233int 237int
260 264
261 PUTBACK; 265 PUTBACK;
262 int count = call_pv ("cf::inject_command", G_SCALAR | G_EVAL); 266 int count = call_pv ("cf::inject_command", G_SCALAR | G_EVAL);
263 SPAGAIN; 267 SPAGAIN;
264 268
269 if (SvTRUE (ERRSV))
270 LOG (llevError, "command '%s' callback evaluation error: %s", rtn_cmd.name, SvPV_nolen (ERRSV));
271
265 int returnvalue = count > 0 ? POPi : -1; 272 int returnvalue = count > 0 ? POPi : -1;
266 273
267 PUTBACK; 274 PUTBACK;
268 FREETMPS; 275 FREETMPS;
269 LEAVE; 276 LEAVE;
270
271 if (SvTRUE (ERRSV))
272 LOG (llevError, "command '%s' callback evaluation error: %s", rtn_cmd.name, SvPV_nolen (ERRSV));
273 277
274 return returnvalue; 278 return returnvalue;
275} 279}
276 280
277void * 281void *
281 char *propname; 285 char *propname;
282 int i; 286 int i;
283 va_start (args, type); 287 va_start (args, type);
284 propname = va_arg (args, char *); 288 propname = va_arg (args, char *);
285 //printf ("Property name: %s\n", propname); 289 //printf ("Property name: %s\n", propname);
286 290
287 if (!strcmp (propname, "command?")) 291 if (!strcmp (propname, "command?"))
288 { 292 {
293 if (!perl)
294 return NULL;
295
289 const char *cmdname = va_arg (args, const char *); 296 const char *cmdname = va_arg (args, const char *);
290 HV *hv = get_hv ("cf::COMMAND", 1); 297 HV *hv = get_hv ("cf::COMMAND", 1);
291 SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0); 298 SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0);
292 299
293 va_end (args); 300 va_end (args);
329 printf (PLUGIN_VERSION " post init\n"); 336 printf (PLUGIN_VERSION " post init\n");
330 337
331 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); 338 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event");
332 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); 339 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event");
333 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); 340 systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory");
341 object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property");
334 reCmp = gethook (&rtype, hooktype, "cfapi_system_re_cmp"); 342 map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map");
343
335 cf_init_plugin (gethook); 344 cf_init_plugin (gethook);
336 345
337 /* Pick the global events you want to monitor from this plugin */ 346 /* Pick the global events you want to monitor from this plugin */
338 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); 347 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener);
339 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); 348 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener);
354 char *argv[] = { 363 char *argv[] = {
355 "", 364 "",
356 "-e" 365 "-e"
357 "BEGIN {" 366 "BEGIN {"
358 " cf->bootstrap;" 367 " cf->bootstrap;"
359 " unshift @INC, cf::get_maps_directory ('perl');" 368 " unshift @INC, cf::datadir ();"
360 "}" 369 "}"
361 "" 370 ""
362 "use cf;" 371 "use cf;"
363 }; 372 };
364 373
365 perl = perl_alloc (); 374 perl = perl_alloc ();
366 perl_construct (perl); 375 perl_construct (perl);
367 376
368 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 377 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
369 || perl_run (perl))
370 { 378 {
371 printf ("unable to initialize perl-interpreter, continuing without.\n"); 379 printf ("unable to initialize perl-interpreter, continuing without.\n");
372 380
373 perl_destruct (perl); 381 perl_destruct (perl);
374 perl_free (perl); 382 perl_free (perl);
540 548
541BOOT: 549BOOT:
542{ 550{
543 HV *stash = gv_stashpv ("cf", 1); 551 HV *stash = gv_stashpv ("cf", 1);
544 552
545 const struct { 553 static const struct {
546 const char *name; 554 const char *name;
547 IV iv; 555 IV iv;
548 } *civ, const_iv[] = { 556 } *civ, const_iv[] = {
549# define const_iv(name) { # name, (IV)name }, 557# define const_iv(name) { # name, (IV)name },
550 const_iv (llevError) 558 const_iv (llevError)
801 const_iv (FLAG_IS_WATER) 809 const_iv (FLAG_IS_WATER)
802 const_iv (FLAG_CONTENT_ON_GEN) 810 const_iv (FLAG_CONTENT_ON_GEN)
803 const_iv (FLAG_IS_A_TEMPLATE) 811 const_iv (FLAG_IS_A_TEMPLATE)
804 const_iv (FLAG_IS_BUILDABLE) 812 const_iv (FLAG_IS_BUILDABLE)
805 const_iv (FLAG_AFK) 813 const_iv (FLAG_AFK)
814
815 const_iv (NDI_BLACK)
816 const_iv (NDI_WHITE)
817 const_iv (NDI_NAVY)
818 const_iv (NDI_RED)
819 const_iv (NDI_ORANGE)
820 const_iv (NDI_BLUE)
821 const_iv (NDI_DK_ORANGE)
822 const_iv (NDI_GREEN)
823 const_iv (NDI_LT_GREEN)
824 const_iv (NDI_GREY)
825 const_iv (NDI_BROWN)
826 const_iv (NDI_GOLD)
827 const_iv (NDI_TAN)
828 const_iv (NDI_MAX_COLOR)
829 const_iv (NDI_COLOR_MASK)
830 const_iv (NDI_UNIQUE)
831 const_iv (NDI_ALL)
832
833 const_iv (F_APPLIED)
834 const_iv (F_LOCATION)
835 const_iv (F_UNPAID)
836 const_iv (F_MAGIC)
837 const_iv (F_CURSED)
838 const_iv (F_DAMNED)
839 const_iv (F_OPEN)
840 const_iv (F_NOPICK)
841 const_iv (F_LOCKED)
842
843 const_iv (P_BLOCKSVIEW)
844 const_iv (P_NO_MAGIC)
845 const_iv (P_IS_ALIVE)
846 const_iv (P_NO_CLERIC)
847 const_iv (P_NEED_UPDATE)
848 const_iv (P_NO_ERROR)
849 const_iv (P_OUT_OF_MAP)
850 const_iv (P_NEW_MAP)
806 }; 851 };
807 852
808 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) 853 for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; )
809 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 854 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
810 855
811 const struct { 856 static const struct {
812 const char *name; 857 const char *name;
813 IV iv; 858 IV iv;
814 } *event, event_list[] = { 859 } *event, event_list[] = {
815# define const_event(name) { # name, (IV)EVENT_ ## name }, 860# define const_event(name) { # name, (IV)EVENT_ ## name },
816 const_event (NONE) 861 const_event (NONE)
847 AV *av = get_av ("cf::EVENT", 1); 892 AV *av = get_av ("cf::EVENT", 1);
848 893
849 for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) 894 for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; )
850 av_store (av, event->iv, newSVpv ((char *)event->name, 0)); 895 av_store (av, event->iv, newSVpv ((char *)event->name, 0));
851 896
852 const struct { 897 static const struct {
853 int dtype; 898 int dtype;
854 const char *name; 899 const char *name;
855 IV idx; 900 IV idx;
856 } *cprop, prop_table[] = { 901 } *cprop, prop_table[] = {
857# define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, 902# define prop(type, name) { type, # name, (IV) CFAPI_ ## name },
973 prop (CFAPI_INT, OBJECT_PROP_DAM) 1018 prop (CFAPI_INT, OBJECT_PROP_DAM)
974 prop (CFAPI_STRING, OBJECT_PROP_GOD) 1019 prop (CFAPI_STRING, OBJECT_PROP_GOD)
975 prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME) 1020 prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME)
976 prop (CFAPI_INT, OBJECT_PROP_INVISIBLE) 1021 prop (CFAPI_INT, OBJECT_PROP_INVISIBLE)
977 prop (CFAPI_INT, OBJECT_PROP_FACE) 1022 prop (CFAPI_INT, OBJECT_PROP_FACE)
978 prop (CFAPI_STRING, PLAYER_PROP_IP)
979 prop (CFAPI_POBJECT, PLAYER_PROP_MARKED_ITEM)
980 prop (CFAPI_PPARTY, PLAYER_PROP_PARTY)
981 }; 1023 };
982 1024
983 HV *prop_type = get_hv ("cf::PROP_TYPE", 1); 1025 HV *prop_type = get_hv ("cf::PROP_TYPE", 1);
984 HV *prop_idx = get_hv ("cf::PROP_IDX", 1); 1026 HV *prop_idx = get_hv ("cf::PROP_IDX", 1);
985 1027
990 } 1032 }
991} 1033}
992 1034
993void 1035void
994LOG (int level, char *msg) 1036LOG (int level, char *msg)
1037 PROTOTYPE: $$
995 C_ARGS: level, "%s", msg 1038 C_ARGS: level, "%s", msg
996 1039
997char * 1040char *
998cf_get_maps_directory (char *path) 1041cf_get_maps_directory (char *path)
1042 PROTOTYPE: $
1043 ALIAS: maps_directory = 0
1044
1045char *
1046mapdir ()
1047 PROTOTYPE:
1048 ALIAS:
1049 mapdir = 0
1050 uniquedir = 1
1051 tmpdir = 2
1052 confdir = 3
1053 localdir = 4
1054 playerdir = 5
1055 datadir = 6
1056 CODE:
1057{
1058 int unused_type;
1059 RETVAL = (char *)systemDirectory (&unused_type, ix);
1060}
1061 OUTPUT: RETVAL
1062
1063int
1064cf_find_animation (char *text)
1065 PROTOTYPE: $
999 1066
1000MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1067MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1001 1068
1002PROTOTYPES: DISABLE
1003
1004SV * 1069SV *
1005cf_object_get_property (object *obj, int type, int idx) 1070get_property (object *obj, int type, int idx)
1006 CODE: 1071 CODE:
1007 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); 1072 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx));
1008 OUTPUT: 1073 OUTPUT: RETVAL
1009 RETVAL 1074
1075SV *
1076set_property (object *obj, int type, int idx, SV *newval)
1077 CODE:
1078 switch (type)
1079 {
1080 case CFAPI_INT:
1081 cf_object_set_int_property (obj, idx, SvIV (newval));
1082 break;
1083 case CFAPI_LONG:
1084 cf_object_set_long_property (obj, idx, SvNV (newval));
1085 break;
1086 case CFAPI_DOUBLE:
1087 {
1088 int unused_type;
1089 object_set_property (&unused_type, obj, idx, (double)SvNV (newval));
1090 }
1091 break;
1092 case CFAPI_STRING:
1093 cf_object_set_string_property (obj, idx, SvPV_nolen (newval));
1094 break;
1095 default:
1096 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1097 }
1098
1099SV *
1100inv (object *obj)
1101 PROTOTYPE: $
1102 PPCODE:
1103{
1104 object *o;
1105 for (o = obj->inv; o; o = o->below)
1106 XPUSHs (newSVcfapi (CFAPI_POBJECT, o));
1107}
1010 1108
1011int cf_object_get_resistance (object *op, int rtype) 1109int cf_object_get_resistance (object *op, int rtype)
1110 ALIAS: resistance = 0
1012 1111
1013int cf_object_get_flag (object *op, int flag) 1112int cf_object_get_flag (object *op, int flag)
1014 ALIAS: flag = 0 1113 ALIAS: flag = 0
1015 1114
1016void cf_object_set_flag (object *op, int flag, int value) 1115void cf_object_set_flag (object *op, int flag, int value)
1046void cf_object_forget_spell (object *op, object *sp) 1145void cf_object_forget_spell (object *op, object *sp)
1047 1146
1048object *cf_object_check_for_spell (object *op, char *spellname) 1147object *cf_object_check_for_spell (object *op, char *spellname)
1049 1148
1050int cf_object_query_money (object *op) 1149int cf_object_query_money (object *op)
1150 ALIAS: money = 0
1051 1151
1052int cf_object_query_cost (object *op, object *who, int flags) 1152int cf_object_query_cost (object *op, object *who, int flags)
1153 ALIAS: cost = 0
1053 1154
1054void cf_object_activate_rune (object *op , object *victim) 1155void cf_object_activate_rune (object *op , object *victim)
1055 1156
1056int cf_object_check_trigger (object *op, object *cause) 1157int cf_object_check_trigger (object *op, object *cause)
1057 1158
1066void cf_object_speak (object *op, char *msg) 1167void cf_object_speak (object *op, char *msg)
1067 1168
1068object *cf_object_insert_object (object *op, object *container) 1169object *cf_object_insert_object (object *op, object *container)
1069 1170
1070const char *cf_object_get_msg (object *ob) 1171const char *cf_object_get_msg (object *ob)
1172 ALIAS: msg = 0
1071 1173
1072object *cf_object_insert_in_ob (object *ob, object *where) 1174object *cf_object_insert_in_ob (object *ob, object *where)
1073 1175
1074int cf_object_teleport (object *op, mapstruct *map, int x, int y) 1176int cf_object_teleport (object *op, mapstruct *map, int x, int y)
1075 1177
1076void cf_object_update (object *op, int flags) 1178void cf_object_update (object *op, int flags)
1077 1179
1078void cf_object_pickup (object *op, object *what) 1180void cf_object_pickup (object *op, object *what)
1079 1181
1080char *cf_object_get_key (object *op, char *keyname) 1182char *cf_object_get_key (object *op, char *keyname)
1183 ALIAS: key = 0
1081 1184
1082void cf_object_set_key (object *op, char *keyname, char *value) 1185void cf_object_set_key (object *op, char *keyname, char *value)
1083 1186
1084char * 1187char *
1085base_name (object *ob, int plural) 1188base_name (object *ob, int plural)
1086 CODE: 1189 CODE:
1087 RETVAL = cf_query_base_name (ob, plural); 1190 RETVAL = cf_query_base_name (ob, plural);
1191 OUTPUT: RETVAL
1192
1193MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1194
1195object *cf_create_object_by_name (const char *name = 0)
1196 PROTOTYPE: ;$
1197 ALIAS:
1198 create_object = 0
1199 new = 0
1200 CODE:
1201 RETVAL = name ? cf_create_object_by_name (name) : cf_create_object ();
1088 OUTPUT: 1202 OUTPUT:
1089 RETVAL 1203 RETVAL
1090
1091MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1092
1093object *cf_create_object ()
1094
1095object *cf_create_object_by_name (const char *name)
1096
1097void cf_free_object (object *ob)
1098 1204
1099void cf_fix_object (object *pl) 1205void cf_fix_object (object *pl)
1206 ALIAS: fix = 0
1100 1207
1101object *cf_insert_ob_in_ob (object *ob, object *where) 1208object *cf_insert_ob_in_ob (object *ob, object *where)
1102 1209
1103 1210
1104MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1211MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1105 1212
1106player *player (object *op) 1213player *player (object *op)
1107 CODE: 1214 CODE:
1108 RETVAL = cf_player_find (cf_query_name (op)); 1215 RETVAL = cf_player_find (cf_query_name (op));
1109 OUTPUT: 1216 OUTPUT: RETVAL
1110 RETVAL
1111 1217
1112void cf_player_message (object *obj, char *txt, int flags = 0) 1218void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1113 1219
1114object *cf_player_send_inventory (object *op) 1220object *cf_player_send_inventory (object *op)
1115 1221
1222char *cf_player_get_ip (object *op)
1223 ALIAS: ip = 0
1224
1225object *cf_player_get_marked_item (object *op)
1226 ALIAS: marked_item = 0
1227
1228void cf_player_set_marked_item (object *op, object *ob)
1229
1230partylist *cf_player_get_party (object *op)
1231 ALIAS: party = 0
1232
1233void cf_player_set_party (object *op, partylist *party)
1234
1116 1235
1117MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ 1236MODULE = cf PACKAGE = cf::object::map PREFIX = cf_
1118 1237
1119mapstruct *cf_map_get_map (char *name)
1120
1121mapstruct *cf_map_get_first ()
1122
1123object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1124
1125object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1126
1127object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1128 C_ARGS: str, map, nx, ny
1129
1130#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1131
1132
1133MODULE = cf PACKAGE = cf::player PREFIX = cf_ 1238MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
1134 1239
1135player *cf_player_find (char *name) 1240player *cf_player_find (char *name)
1241 PROTOTYPE: $
1136 1242
1137void cf_player_move (player *pl, int dir) 1243void cf_player_move (player *pl, int dir)
1138 1244
1245# nonstandard
1246object *ob (player *pl)
1247 CODE:
1248 RETVAL = pl->ob;
1249 OUTPUT: RETVAL
1139 1250
1251
1140MODULE = cf PACKAGE = cf::map PREFIX = cf_ 1252MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
1141 1253
1142SV * 1254SV *
1143get_property (mapstruct *obj, int type, int idx) 1255get_property (mapstruct *obj, int type, int idx)
1144 CODE: 1256 CODE:
1145 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); 1257 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx));
1258 OUTPUT: RETVAL
1259
1260SV *
1261set_property (mapstruct *obj, int type, int idx, SV *newval)
1262 CODE:
1263 switch (type)
1264 {
1265 case CFAPI_INT:
1266 cf_map_set_int_property (obj, idx, SvIV (newval));
1267 break;
1268 default:
1269 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1270 }
1271
1272mapstruct *new (int width, int height)
1273 PROTOTYPE:
1274 CODE:
1275{
1276 int unused_type;
1277 RETVAL = map_get_map (&unused_type, 0, width, height);
1278}
1146 OUTPUT: 1279 OUTPUT:
1147 RETVAL 1280 RETVAL
1281
1282mapstruct *cf_map_get_map (char *name)
1283 PROTOTYPE: $
1284 ALIAS: map = 0
1285
1286mapstruct *cf_map_get_first ()
1287 PROTOTYPE:
1288 ALIAS: first = 0
1289
1290object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1291
1292object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1293
1294object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1295 C_ARGS: str, map, nx, ny
1296
1297#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1298
1299SV *
1300at (mapstruct *obj, unsigned int x, unsigned int y)
1301 PROTOTYPE: $$$
1302 INIT:
1303 if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF;
1304 PPCODE:
1305{
1306 object *o;
1307 for (o = GET_MAP_OB (obj, x, y); o; o = o->above)
1308 XPUSHs (newSVcfapi (CFAPI_POBJECT, o));
1309}
1310
1311SV *
1312bot_at (mapstruct *obj, unsigned int x, unsigned int y)
1313 PROTOTYPE: $$$
1314 ALIAS:
1315 top_at = 1
1316 flags_at = 2
1317 light_at = 3
1318 move_block_at = 4
1319 move_slow_at = 5
1320 move_on_at = 6
1321 move_off_at = 7
1322 INIT:
1323 if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF;
1324 CODE:
1325 switch (ix)
1326 {
1327 case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break;
1328 case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break;
1329 case 2: RETVAL = newSVuv ( GET_MAP_FLAGS (obj, x, y)); break;
1330 case 3: RETVAL = newSViv ( GET_MAP_LIGHT (obj, x, y)); break;
1331 case 4: RETVAL = newSVuv ( GET_MAP_MOVE_BLOCK (obj, x, y)); break;
1332 case 5: RETVAL = newSVuv ( GET_MAP_MOVE_SLOW (obj, x, y)); break;
1333 case 6: RETVAL = newSVuv ( GET_MAP_MOVE_ON (obj, x, y)); break;
1334 case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break;
1335 }
1336 OUTPUT:
1337 RETVAL
1148 1338
1149 1339
1150MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ 1340MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_
1151 1341
1152archetype*cf_archetype_get_first() 1342archetype *cf_archetype_get_first()
1343 PROTOTYPE:
1344 ALIAS: first = 0
1345
1346archetype *cf_archetype_get_next (archetype *arch)
1347 ALIAS: next = 0
1348
1349archetype *cf_archetype_get_head (archetype *arch)
1350 ALIAS: head = 0
1351
1352archetype *cf_archetype_get_more (archetype *arch)
1353 ALIAS: more = 0
1153 1354
1154const char *cf_archetype_get_name (archetype *arch) 1355const char *cf_archetype_get_name (archetype *arch)
1155 1356 ALIAS: name = 0
1156archetype *cf_archetype_get_next (archetype *arch)
1157
1158archetype *cf_archetype_get_more (archetype *arch)
1159
1160archetype *cf_archetype_get_head (archetype *arch)
1161 1357
1162MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ 1358MODULE = cf PACKAGE = cf::party PREFIX = cf_party_
1163 1359
1164const char *cf_party_get_name (partylist *party)
1165
1166partylist *cf_party_get_first () 1360partylist *cf_party_get_first ()
1361 PROTOTYPE:
1167 ALIAS: first = 0 1362 ALIAS: first = 0
1168 1363
1169partylist *cf_party_get_next (partylist *party) 1364partylist *cf_party_get_next (partylist *party)
1170 ALIAS: next = 0 1365 ALIAS: next = 0
1171 1366
1367const char *cf_party_get_name (partylist *party)
1368
1172const char *cf_party_get_password (partylist *party) 1369const char *cf_party_get_password (partylist *party)
1173 ALIAS: password = 0 1370 ALIAS: password = 0
1174 1371
1175player *cf_party_get_first_player (partylist *party) 1372player *cf_party_get_first_player (partylist *party)
1176 ALIAS: first_player = 0 1373 ALIAS: first_player = 0
1180 1377
1181 1378
1182MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ 1379MODULE = cf PACKAGE = cf::region PREFIX = cf_region_
1183 1380
1184region *cf_region_get_first () 1381region *cf_region_get_first ()
1382 PROTOTYPE:
1185 ALIAS: first = 0 1383 ALIAS: first = 0
1186 1384
1187const char *cf_region_get_name (region *reg) 1385const char *cf_region_get_name (region *reg)
1188 ALIAS: name = 0 1386 ALIAS: name = 0
1189 1387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines