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.2 by root, Fri Feb 3 07:51:14 2006 UTC vs.
Revision 1.11 by root, Tue Feb 7 00:56:00 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::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: $
999 ALIAS: maps_directory = 0 1043 ALIAS: maps_directory = 0
1000 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: $
1066
1001MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1067MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1002 1068
1003PROTOTYPES: DISABLE
1004
1005SV * 1069SV *
1006cf_object_get_property (object *obj, int type, int idx) 1070get_property (object *obj, int type, int idx)
1007 CODE: 1071 CODE:
1008 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); 1072 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx));
1009 OUTPUT: 1073 OUTPUT: RETVAL
1010 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 }
1011 1098
1012int cf_object_get_resistance (object *op, int rtype) 1099int cf_object_get_resistance (object *op, int rtype)
1013 ALIAS: resistance = 0 1100 ALIAS: resistance = 0
1014 1101
1015int cf_object_get_flag (object *op, int flag) 1102int cf_object_get_flag (object *op, int flag)
1089 1176
1090char * 1177char *
1091base_name (object *ob, int plural) 1178base_name (object *ob, int plural)
1092 CODE: 1179 CODE:
1093 RETVAL = cf_query_base_name (ob, plural); 1180 RETVAL = cf_query_base_name (ob, plural);
1181 OUTPUT: RETVAL
1182
1183MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1184
1185object *cf_create_object_by_name (const char *name = 0)
1186 PROTOTYPE: ;$
1187 ALIAS:
1188 create_object = 0
1189 new = 0
1190 CODE:
1191 RETVAL = name ? cf_create_object_by_name (name) : cf_create_object ();
1094 OUTPUT: 1192 OUTPUT:
1095 RETVAL 1193 RETVAL
1096
1097MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1098
1099object *cf_create_object ()
1100 ALIAS: new = 0
1101
1102object *cf_create_object_by_name (const char *name)
1103 ALIAS: new_from_name = 0
1104
1105void cf_free_object (object *ob)
1106 1194
1107void cf_fix_object (object *pl) 1195void cf_fix_object (object *pl)
1196 ALIAS: fix = 0
1108 1197
1109object *cf_insert_ob_in_ob (object *ob, object *where) 1198object *cf_insert_ob_in_ob (object *ob, object *where)
1110 1199
1111 1200
1112MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1201MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1113 1202
1114player *player (object *op) 1203player *player (object *op)
1115 CODE: 1204 CODE:
1116 RETVAL = cf_player_find (cf_query_name (op)); 1205 RETVAL = cf_player_find (cf_query_name (op));
1117 OUTPUT: 1206 OUTPUT: RETVAL
1118 RETVAL
1119 1207
1120void cf_player_message (object *obj, char *txt, int flags = 0) 1208void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1121 1209
1122object *cf_player_send_inventory (object *op) 1210object *cf_player_send_inventory (object *op)
1123 1211
1212char *cf_player_get_ip (object *op)
1213 ALIAS: ip = 0
1214
1215object *cf_player_get_marked_item (object *op)
1216 ALIAS: marked_item = 0
1217
1218void cf_player_set_marked_item (object *op, object *ob)
1219
1220partylist *cf_player_get_party (object *op)
1221 ALIAS: party = 0
1222
1223void cf_player_set_party (object *op, partylist *party)
1224
1124 1225
1125MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ 1226MODULE = cf PACKAGE = cf::object::map PREFIX = cf_
1126 1227
1127mapstruct *cf_map_get_map (char *name)
1128 ALIAS: map = 0
1129
1130mapstruct *cf_map_get_first ()
1131 ALIAS: first = 0
1132
1133object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1134
1135object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1136
1137object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1138 C_ARGS: str, map, nx, ny
1139
1140#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1141
1142
1143MODULE = cf PACKAGE = cf::player PREFIX = cf_ 1228MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
1144 1229
1145player *cf_player_find (char *name) 1230player *cf_player_find (char *name)
1231 PROTOTYPE: $
1146 1232
1147void cf_player_move (player *pl, int dir) 1233void cf_player_move (player *pl, int dir)
1148 1234
1235# nonstandard
1236object *ob (player *pl)
1237 CODE:
1238 RETVAL = pl->ob;
1239 OUTPUT: RETVAL
1149 1240
1241
1150MODULE = cf PACKAGE = cf::map PREFIX = cf_ 1242MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
1151 1243
1152SV * 1244SV *
1153get_property (mapstruct *obj, int type, int idx) 1245get_property (mapstruct *obj, int type, int idx)
1154 CODE: 1246 CODE:
1155 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); 1247 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx));
1248 OUTPUT: RETVAL
1249
1250SV *
1251set_property (mapstruct *obj, int type, int idx, SV *newval)
1252 CODE:
1253 switch (type)
1254 {
1255 case CFAPI_INT:
1256 cf_map_set_int_property (obj, idx, SvIV (newval));
1257 break;
1258 default:
1259 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1260 }
1261
1262mapstruct *new (int width, int height)
1263 PROTOTYPE:
1264 CODE:
1265{
1266 int unused_type;
1267 RETVAL = map_get_map (&unused_type, 0, width, height);
1268}
1156 OUTPUT: 1269 OUTPUT:
1157 RETVAL 1270 RETVAL
1271
1272mapstruct *cf_map_get_map (char *name)
1273 PROTOTYPE: $
1274 ALIAS: map = 0
1275
1276mapstruct *cf_map_get_first ()
1277 PROTOTYPE:
1278 ALIAS: first = 0
1279
1280object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1281
1282object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1283
1284object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1285 C_ARGS: str, map, nx, ny
1286
1287#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1288
1289SV *at (mapstruct *obj, unsigned int x, unsigned int y)
1290 PROTOTYPE: $$$
1291 INIT:
1292 if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF;
1293 PPCODE:
1294{
1295 object *o;
1296 for (o = GET_MAP_OB (obj, x, y); o; o = o->above)
1297 XPUSHs (newSVcfapi (CFAPI_POBJECT, o));
1298}
1299
1300SV *bot_at (mapstruct *obj, unsigned int x, unsigned int y)
1301 PROTOTYPE: $$$
1302 ALIAS:
1303 top_at = 1
1304 flags_at = 2
1305 light_at = 3
1306 move_block_at = 4
1307 move_slow_at = 5
1308 move_on_at = 6
1309 move_off_at = 7
1310 INIT:
1311 if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF;
1312 CODE:
1313 switch (ix)
1314 {
1315 case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break;
1316 case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break;
1317 case 2: RETVAL = newSVuv ( GET_MAP_FLAGS (obj, x, y)); break;
1318 case 3: RETVAL = newSViv ( GET_MAP_LIGHT (obj, x, y)); break;
1319 case 4: RETVAL = newSVuv ( GET_MAP_MOVE_BLOCK (obj, x, y)); break;
1320 case 5: RETVAL = newSVuv ( GET_MAP_MOVE_SLOW (obj, x, y)); break;
1321 case 6: RETVAL = newSVuv ( GET_MAP_MOVE_ON (obj, x, y)); break;
1322 case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break;
1323 }
1324 OUTPUT:
1325 RETVAL
1158 1326
1159 1327
1160MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ 1328MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_
1161 1329
1162archetype*cf_archetype_get_first() 1330archetype*cf_archetype_get_first()
1331 PROTOTYPE:
1163 ALIAS: first = 0 1332 ALIAS: first = 0
1164 1333
1165archetype *cf_archetype_get_next (archetype *arch) 1334archetype *cf_archetype_get_next (archetype *arch)
1166 ALIAS: next = 0 1335 ALIAS: next = 0
1167 1336
1174const char *cf_archetype_get_name (archetype *arch) 1343const char *cf_archetype_get_name (archetype *arch)
1175 ALIAS: name = 0 1344 ALIAS: name = 0
1176 1345
1177MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ 1346MODULE = cf PACKAGE = cf::party PREFIX = cf_party_
1178 1347
1179const char *cf_party_get_name (partylist *party)
1180
1181partylist *cf_party_get_first () 1348partylist *cf_party_get_first ()
1349 PROTOTYPE:
1182 ALIAS: first = 0 1350 ALIAS: first = 0
1183 1351
1184partylist *cf_party_get_next (partylist *party) 1352partylist *cf_party_get_next (partylist *party)
1185 ALIAS: next = 0 1353 ALIAS: next = 0
1186 1354
1355const char *cf_party_get_name (partylist *party)
1356
1187const char *cf_party_get_password (partylist *party) 1357const char *cf_party_get_password (partylist *party)
1188 ALIAS: password = 0 1358 ALIAS: password = 0
1189 1359
1190player *cf_party_get_first_player (partylist *party) 1360player *cf_party_get_first_player (partylist *party)
1191 ALIAS: first_player = 0 1361 ALIAS: first_player = 0
1195 1365
1196 1366
1197MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ 1367MODULE = cf PACKAGE = cf::region PREFIX = cf_region_
1198 1368
1199region *cf_region_get_first () 1369region *cf_region_get_first ()
1370 PROTOTYPE:
1200 ALIAS: first = 0 1371 ALIAS: first = 0
1201 1372
1202const char *cf_region_get_name (region *reg) 1373const char *cf_region_get_name (region *reg)
1203 ALIAS: name = 0 1374 ALIAS: name = 0
1204 1375

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines