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.4 by root, Fri Feb 3 17:19:13 2006 UTC vs.
Revision 1.13 by root, Tue Feb 7 03:06:01 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 *
332 printf (PLUGIN_VERSION " post init\n"); 336 printf (PLUGIN_VERSION " post init\n");
333 337
334 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); 338 registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event");
335 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); 339 unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event");
336 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");
337 reCmp = gethook (&rtype, hooktype, "cfapi_system_re_cmp"); 342 map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map");
343
338 cf_init_plugin (gethook); 344 cf_init_plugin (gethook);
339 345
340 /* Pick the global events you want to monitor from this plugin */ 346 /* Pick the global events you want to monitor from this plugin */
341 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); 347 registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener);
342 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); 348 registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener);
357 char *argv[] = { 363 char *argv[] = {
358 "", 364 "",
359 "-e" 365 "-e"
360 "BEGIN {" 366 "BEGIN {"
361 " cf->bootstrap;" 367 " cf->bootstrap;"
362 " unshift @INC, cf::maps_directory ('perl');" 368 " unshift @INC, cf::datadir ();"
363 "}" 369 "}"
364 "" 370 ""
365 "use cf;" 371 "use cf;"
366 }; 372 };
367 373
368 perl = perl_alloc (); 374 perl = perl_alloc ();
369 perl_construct (perl); 375 perl_construct (perl);
370 376
371 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) 377 if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl))
372 || perl_run (perl))
373 { 378 {
374 printf ("unable to initialize perl-interpreter, continuing without.\n"); 379 printf ("unable to initialize perl-interpreter, continuing without.\n");
375 380
376 perl_destruct (perl); 381 perl_destruct (perl);
377 perl_free (perl); 382 perl_free (perl);
543 548
544BOOT: 549BOOT:
545{ 550{
546 HV *stash = gv_stashpv ("cf", 1); 551 HV *stash = gv_stashpv ("cf", 1);
547 552
548 const struct { 553 static const struct {
549 const char *name; 554 const char *name;
550 IV iv; 555 IV iv;
551 } *civ, const_iv[] = { 556 } *civ, const_iv[] = {
552# define const_iv(name) { # name, (IV)name }, 557# define const_iv(name) { # name, (IV)name },
553 const_iv (llevError) 558 const_iv (llevError)
804 const_iv (FLAG_IS_WATER) 809 const_iv (FLAG_IS_WATER)
805 const_iv (FLAG_CONTENT_ON_GEN) 810 const_iv (FLAG_CONTENT_ON_GEN)
806 const_iv (FLAG_IS_A_TEMPLATE) 811 const_iv (FLAG_IS_A_TEMPLATE)
807 const_iv (FLAG_IS_BUILDABLE) 812 const_iv (FLAG_IS_BUILDABLE)
808 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)
809 }; 851 };
810 852
811 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; )
812 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 854 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
813 855
814 const struct { 856 static const struct {
815 const char *name; 857 const char *name;
816 IV iv; 858 IV iv;
817 } *event, event_list[] = { 859 } *event, event_list[] = {
818# define const_event(name) { # name, (IV)EVENT_ ## name }, 860# define const_event(name) { # name, (IV)EVENT_ ## name },
819 const_event (NONE) 861 const_event (NONE)
850 AV *av = get_av ("cf::EVENT", 1); 892 AV *av = get_av ("cf::EVENT", 1);
851 893
852 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; )
853 av_store (av, event->iv, newSVpv ((char *)event->name, 0)); 895 av_store (av, event->iv, newSVpv ((char *)event->name, 0));
854 896
855 const struct { 897 static const struct {
856 int dtype; 898 int dtype;
857 const char *name; 899 const char *name;
858 IV idx; 900 IV idx;
859 } *cprop, prop_table[] = { 901 } *cprop, prop_table[] = {
860# define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, 902# define prop(type, name) { type, # name, (IV) CFAPI_ ## name },
976 prop (CFAPI_INT, OBJECT_PROP_DAM) 1018 prop (CFAPI_INT, OBJECT_PROP_DAM)
977 prop (CFAPI_STRING, OBJECT_PROP_GOD) 1019 prop (CFAPI_STRING, OBJECT_PROP_GOD)
978 prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME) 1020 prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME)
979 prop (CFAPI_INT, OBJECT_PROP_INVISIBLE) 1021 prop (CFAPI_INT, OBJECT_PROP_INVISIBLE)
980 prop (CFAPI_INT, OBJECT_PROP_FACE) 1022 prop (CFAPI_INT, OBJECT_PROP_FACE)
981 prop (CFAPI_STRING, PLAYER_PROP_IP)
982 prop (CFAPI_POBJECT, PLAYER_PROP_MARKED_ITEM)
983 prop (CFAPI_PPARTY, PLAYER_PROP_PARTY)
984 }; 1023 };
985 1024
986 HV *prop_type = get_hv ("cf::PROP_TYPE", 1); 1025 HV *prop_type = get_hv ("cf::PROP_TYPE", 1);
987 HV *prop_idx = get_hv ("cf::PROP_IDX", 1); 1026 HV *prop_idx = get_hv ("cf::PROP_IDX", 1);
988 1027
993 } 1032 }
994} 1033}
995 1034
996void 1035void
997LOG (int level, char *msg) 1036LOG (int level, char *msg)
1037 PROTOTYPE: $$
998 C_ARGS: level, "%s", msg 1038 C_ARGS: level, "%s", msg
999 1039
1000char * 1040char *
1001cf_get_maps_directory (char *path) 1041cf_get_maps_directory (char *path)
1042 PROTOTYPE: $
1002 ALIAS: maps_directory = 0 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
1003 1062
1004int 1063int
1005cf_find_animation (char *text) 1064cf_find_animation (char *text)
1065 PROTOTYPE: $
1006 1066
1007MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ 1067MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1008
1009PROTOTYPES: DISABLE
1010 1068
1011SV * 1069SV *
1012get_property (object *obj, int type, int idx) 1070get_property (object *obj, int type, int idx)
1013 CODE: 1071 CODE:
1014 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); 1072 RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx));
1015 OUTPUT: 1073 OUTPUT: RETVAL
1016 RETVAL
1017 1074
1018SV * 1075SV *
1019set_property (object *obj, int type, int idx, SV *newval) 1076set_property (object *obj, int type, int idx, SV *newval)
1020 CODE: 1077 CODE:
1021 switch (type) 1078 switch (type)
1024 cf_object_set_int_property (obj, idx, SvIV (newval)); 1081 cf_object_set_int_property (obj, idx, SvIV (newval));
1025 break; 1082 break;
1026 case CFAPI_LONG: 1083 case CFAPI_LONG:
1027 cf_object_set_long_property (obj, idx, SvNV (newval)); 1084 cf_object_set_long_property (obj, idx, SvNV (newval));
1028 break; 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;
1029 case CFAPI_STRING: 1092 case CFAPI_STRING:
1030 cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); 1093 cf_object_set_string_property (obj, idx, SvPV_nolen (newval));
1031 break; 1094 break;
1032 default: 1095 default:
1033 croak ("unhandled type '%d' in set_property '%d'", type, idx); 1096 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1034 } 1097 }
1035 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}
1108
1036int cf_object_get_resistance (object *op, int rtype) 1109int cf_object_get_resistance (object *op, int rtype)
1037 ALIAS: resistance = 0 1110 ALIAS: resistance = 0
1038 1111
1039int cf_object_get_flag (object *op, int flag) 1112int cf_object_get_flag (object *op, int flag)
1040 ALIAS: flag = 0 1113 ALIAS: flag = 0
1041 1114
1042void cf_object_set_flag (object *op, int flag, int value) 1115void cf_object_set_flag (object *op, int flag, int value)
1043 1116
1044void cf_object_move (object *op, object *originator, int dir) 1117void cf_object_move (object *op, object *originator, int dir)
1045 1118
1046void cf_object_apply (object *op, object *author, int flags) 1119void cf_object_apply (object *op, object *author, int flags = 0)
1047 1120
1048void cf_object_apply_below (object *op) 1121void cf_object_apply_below (object *op)
1049 1122
1050void cf_object_remove (object *op) 1123void cf_object_remove (object *op)
1051 1124
1113 1186
1114char * 1187char *
1115base_name (object *ob, int plural) 1188base_name (object *ob, int plural)
1116 CODE: 1189 CODE:
1117 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 ();
1118 OUTPUT: 1202 OUTPUT:
1119 RETVAL 1203 RETVAL
1120
1121MODULE = cf PACKAGE = cf::object PREFIX = cf_object_
1122
1123object *cf_create_object ()
1124 ALIAS: new = 0
1125
1126object *cf_create_object_by_name (const char *name)
1127 ALIAS: new_from_name = 0
1128
1129void cf_free_object (object *ob)
1130 1204
1131void cf_fix_object (object *pl) 1205void cf_fix_object (object *pl)
1206 ALIAS: fix = 0
1132 1207
1133object *cf_insert_ob_in_ob (object *ob, object *where) 1208object *cf_insert_ob_in_ob (object *ob, object *where)
1134 1209
1135 1210
1136MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ 1211MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_
1137 1212
1138player *player (object *op) 1213player *player (object *op)
1139 CODE: 1214 CODE:
1140 RETVAL = cf_player_find (cf_query_name (op)); 1215 RETVAL = cf_player_find (cf_query_name (op));
1141 OUTPUT: 1216 OUTPUT: RETVAL
1142 RETVAL
1143 1217
1144void cf_player_message (object *obj, char *txt, int flags = 0) 1218void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1145 1219
1146object *cf_player_send_inventory (object *op) 1220object *cf_player_send_inventory (object *op)
1147 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
1148void cf_player_set_marked_item(object *op, object *ob) 1228void cf_player_set_marked_item (object *op, object *ob)
1149 1229
1230partylist *cf_player_get_party (object *op)
1231 ALIAS: party = 0
1232
1150void cf_player_set_party(object *op, partylist *party) 1233void cf_player_set_party (object *op, partylist *party)
1151 1234
1152 1235
1153MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ 1236MODULE = cf PACKAGE = cf::object::map PREFIX = cf_
1154 1237
1155MODULE = cf PACKAGE = cf::player PREFIX = cf_ 1238MODULE = cf PACKAGE = cf::player PREFIX = cf_player_
1156 1239
1157player *cf_player_find (char *name) 1240player *cf_player_find (char *name)
1241 PROTOTYPE: $
1158 1242
1159void cf_player_move (player *pl, int dir) 1243void cf_player_move (player *pl, int dir)
1160 1244
1245# nonstandard
1246object *ob (player *pl)
1247 CODE:
1248 RETVAL = pl->ob;
1249 OUTPUT: RETVAL
1161 1250
1251
1162MODULE = cf PACKAGE = cf::map PREFIX = cf_ 1252MODULE = cf PACKAGE = cf::map PREFIX = cf_map_
1163 1253
1164SV * 1254SV *
1165get_property (mapstruct *obj, int type, int idx) 1255get_property (mapstruct *obj, int type, int idx)
1166 CODE: 1256 CODE:
1167 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); 1257 RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx));
1168 OUTPUT: 1258 OUTPUT: RETVAL
1169 RETVAL
1170 1259
1171SV * 1260SV *
1172set_property (mapstruct *obj, int type, int idx, SV *newval) 1261set_property (mapstruct *obj, int type, int idx, SV *newval)
1173 CODE: 1262 CODE:
1174 switch (type) 1263 switch (type)
1178 break; 1267 break;
1179 default: 1268 default:
1180 croak ("unhandled type '%d' in set_property '%d'", type, idx); 1269 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1181 } 1270 }
1182 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}
1279 OUTPUT:
1280 RETVAL
1281
1183mapstruct *cf_map_get_map (char *name) 1282mapstruct *cf_map_get_map (char *name)
1283 PROTOTYPE: $
1184 ALIAS: map = 0 1284 ALIAS: map = 0
1185 1285
1186mapstruct *cf_map_get_first () 1286mapstruct *cf_map_get_first ()
1287 PROTOTYPE:
1187 ALIAS: first = 0 1288 ALIAS: first = 0
1188 1289
1189object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) 1290object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags)
1190 1291
1191object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) 1292object *cf_map_insert_object (mapstruct *where, object* op, int x, int y)
1193object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) 1294object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny)
1194 C_ARGS: str, map, nx, ny 1295 C_ARGS: str, map, nx, ny
1195 1296
1196#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny) 1297#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny)
1197 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
1198 1338
1199 1339
1200MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ 1340MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_
1201 1341
1202archetype*cf_archetype_get_first() 1342archetype *cf_archetype_get_first()
1343 PROTOTYPE:
1203 ALIAS: first = 0 1344 ALIAS: first = 0
1204 1345
1205archetype *cf_archetype_get_next (archetype *arch) 1346archetype *cf_archetype_get_next (archetype *arch)
1206 ALIAS: next = 0 1347 ALIAS: next = 0
1207 1348
1214const char *cf_archetype_get_name (archetype *arch) 1355const char *cf_archetype_get_name (archetype *arch)
1215 ALIAS: name = 0 1356 ALIAS: name = 0
1216 1357
1217MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ 1358MODULE = cf PACKAGE = cf::party PREFIX = cf_party_
1218 1359
1219const char *cf_party_get_name (partylist *party)
1220
1221partylist *cf_party_get_first () 1360partylist *cf_party_get_first ()
1361 PROTOTYPE:
1222 ALIAS: first = 0 1362 ALIAS: first = 0
1223 1363
1224partylist *cf_party_get_next (partylist *party) 1364partylist *cf_party_get_next (partylist *party)
1225 ALIAS: next = 0 1365 ALIAS: next = 0
1226 1366
1367const char *cf_party_get_name (partylist *party)
1368
1227const char *cf_party_get_password (partylist *party) 1369const char *cf_party_get_password (partylist *party)
1228 ALIAS: password = 0 1370 ALIAS: password = 0
1229 1371
1230player *cf_party_get_first_player (partylist *party) 1372player *cf_party_get_first_player (partylist *party)
1231 ALIAS: first_player = 0 1373 ALIAS: first_player = 0
1235 1377
1236 1378
1237MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ 1379MODULE = cf PACKAGE = cf::region PREFIX = cf_region_
1238 1380
1239region *cf_region_get_first () 1381region *cf_region_get_first ()
1382 PROTOTYPE:
1240 ALIAS: first = 0 1383 ALIAS: first = 0
1241 1384
1242const char *cf_region_get_name (region *reg) 1385const char *cf_region_get_name (region *reg)
1243 ALIAS: name = 0 1386 ALIAS: name = 0
1244 1387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines