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.312 by root, Tue Dec 23 06:58:24 2008 UTC vs.
Revision 1.331 by root, Thu Nov 5 14:38:47 2009 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001-2005,2007 by Chachkoff Yann
6 * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de> 5 * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de>
7 * 6 *
8 * Deliantra is free software: you can redistribute it and/or modify 7 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 8 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 9 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 10 * option) any later version.
12 * 11 *
13 * This program is distributed in the hope that it will be useful, 12 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 15 * GNU General Public License for more details.
17 * 16 *
18 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * and the GNU General Public License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 * 20 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include "autoconf.h" 24#include "autoconf.h"
71static int tick_pending; 71static int tick_pending;
72 72
73global gbl_ev; 73global gbl_ev;
74static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 74static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
75static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now; 75static SV *sv_runtime, *sv_tick_start, *sv_next_tick, *sv_now;
76static AV *av_reflect;
76 77
77bitset<NUM_EVENT_TYPES> ev_want_event; 78bitset<NUM_EVENT_TYPES> ev_want_event;
78bitset<NUM_TYPES> ev_want_type; 79bitset<NUM_TYPES> ev_want_type;
79 80
80static HV 81static HV
88 *stash_cf_arch_wrap, 89 *stash_cf_arch_wrap,
89 *stash_cf_party_wrap, 90 *stash_cf_party_wrap,
90 *stash_cf_region_wrap, 91 *stash_cf_region_wrap,
91 *stash_cf_living_wrap; 92 *stash_cf_living_wrap;
92 93
94static SV
95 *cv_cf_do_invoke,
96 *cv_cf__can_merge,
97 *cv_cf_client_send_msg,
98 *cv_cf_tick,
99 *cv_cf_match_match;
100
93#ifndef newSVpv_utf8 101#ifndef newSVpv_utf8
94static inline SV * 102static inline SV *
95newSVpv_utf8 (const char *s) 103newSVpv_utf8 (const char *s)
96{ 104{
97 if (!s) 105 if (!s)
158 SvREFCNT_inc (self); 166 SvREFCNT_inc (self);
159 hv_clear (self); 167 hv_clear (self);
160 sv_unmagic ((SV *)self, PERL_MAGIC_ext); 168 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
161 SvREFCNT_dec (self); 169 SvREFCNT_dec (self);
162 170
163 // self *must* be null now because thats sv_unmagic's job. 171 // self *must* be null now because that's sv_unmagic's job.
164 assert (!this->self); 172 assert (!this->self);
165 } 173 }
166} 174}
167 175
168void 176void
317 fprintf (stderr, "P %p\n", pl); 325 fprintf (stderr, "P %p\n", pl);
318 326
319 for_all_clients (ns) 327 for_all_clients (ns)
320 if (find_backref (ptr, ns)) 328 if (find_backref (ptr, ns))
321 fprintf (stderr, "C %p\n", ns); 329 fprintf (stderr, "C %p\n", ns);
322
323} 330}
324 331
325////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 332//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
326 333
327static SV * 334static SV *
405 croak ("perl code used %s object, but C object is already destroyed, caught", klass); 412 croak ("perl code used %s object, but C object is already destroyed, caught", klass);
406 413
407 return (long)mg->mg_ptr; 414 return (long)mg->mg_ptr;
408} 415}
409 416
410static long 417static long noinline
411SvPTR_ornull (SV *sv, const char *klass) 418SvPTR_ornull (SV *sv, const char *klass)
412{ 419{
413 if (SvOK (sv)) 420 if (SvOK (sv))
414 return SvPTR (sv, klass); 421 return SvPTR (sv, klass);
415 else 422 else
607 va_end (ap); 614 va_end (ap);
608 615
609 return sv; 616 return sv;
610} 617}
611 618
619// typemap support, mostly to avoid excessive inlining
620template<class type>
621static void noinline
622cf_obj_to (SV *arg, type &var)
623{
624 sv_to (arg, var);
625 if (!var)
626 croak ("must not pass invalid/null cf_obj here");
627}
628
629template<class object>
630static void noinline
631cf_obj_ornull_to (SV *arg, object *&var)
632{
633 if (SvOK (arg))
634 {
635 sv_to (arg, var);
636 if (!var)
637 croak ("unable to convert perl object to C++ object");
638 }
639 else
640 var = 0;
641}
642
612////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 643//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
613 644
614SV * 645SV *
615registry (attachable *ext) 646registry (attachable *ext)
616{ 647{
660 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV)); 691 printf ("unable to bootstrap perl, aborting:\n%s", SvPV_nolen (ERRSV));
661 exit (EXIT_FAILURE); 692 exit (EXIT_FAILURE);
662 } 693 }
663} 694}
664 695
696void
665void cfperl_main () 697cfperl_main ()
666{ 698{
667 dSP; 699 dSP;
668 700
669 PUSHMARK (SP); 701 PUSHMARK (SP);
670 PUTBACK; 702 PUTBACK;
695# undef def 727# undef def
696}; 728};
697 729
698#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE) 730#define KLASS_OF(event) (((unsigned int)event) < NUM_EVENT_TYPES ? klass_of [event] : KLASS_NONE)
699 731
700static void 732static void noinline
701gather_callbacks (AV *&callbacks, AV *registry, event_type event) 733gather_callbacks (AV *&callbacks, AV *registry, event_type event)
702{ 734{
703 // event must be in array 735 // event must be in array
704 if (event >= 0 && event <= AvFILLp (registry)) 736 if (event >= 0 && event <= AvFILLp (registry))
705 { 737 {
791{ 823{
792 attachable::gather_callbacks (callbacks, event); 824 attachable::gather_callbacks (callbacks, event);
793 ::gather_callbacks (callbacks, cb_map, event); 825 ::gather_callbacks (callbacks, cb_map, event);
794} 826}
795 827
796void 828static void noinline
797_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry) 829_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
798{ 830{
799 for (int event = 0; event <= AvFILLp (registry); ++event) 831 for (int event = 0; event <= AvFILLp (registry); ++event)
800 { 832 {
801 SV *cbs_ = AvARRAY (registry)[event]; 833 SV *cbs_ = AvARRAY (registry)[event];
811 } 843 }
812 } 844 }
813} 845}
814 846
815// very slow and inefficient way to recalculate the global want bitsets 847// very slow and inefficient way to recalculate the global want bitsets
816void 848static void
817_recalc_want () 849_recalc_want ()
818{ 850{
819 ev_want_event.reset (); 851 ev_want_event.reset ();
820 852
821 _recalc_want (ev_want_event, cb_global); 853 _recalc_want (ev_want_event, cb_global);
894 XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); 926 XPUSHs (sv_2mortal (newSVdt_va (ap, dt)));
895 } 927 }
896 928
897 va_end (ap); 929 va_end (ap);
898 930
899 CALL_CALL ("cf::do_invoke", G_SCALAR); 931 CALL_CALL (cv_cf_do_invoke, G_SCALAR);
900 count = count > 0 ? POPi : 0; 932 count = count > 0 ? POPi : 0;
901 933
902 CALL_END; 934 CALL_END;
903 935
904 return count; 936 return count;
931} 963}
932 964
933///////////////////////////////////////////////////////////////////////////// 965/////////////////////////////////////////////////////////////////////////////
934// various c++ => perl glue functions 966// various c++ => perl glue functions
935 967
968void
936void cfperl_tick () 969cfperl_tick ()
937{ 970{
938 tick_pending = 1; 971 tick_pending = 1;
939 972
940 if (tick_inhibit) 973 if (tick_inhibit)
941 return; 974 return;
944 977
945 dSP; 978 dSP;
946 979
947 PUSHMARK (SP); 980 PUSHMARK (SP);
948 PUTBACK; 981 PUTBACK;
949 call_pv ("cf::tick", G_DISCARD | G_VOID); 982 call_pvsv (cv_cf_tick, G_DISCARD | G_VOID);
950 983
951 SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick); 984 SvNV_set (sv_next_tick, get_next_tick ()); SvNOK_only (sv_next_tick);
952} 985}
953 986
954void 987void
984 CALL_BEGIN (4); 1017 CALL_BEGIN (4);
985 CALL_ARG (ns); 1018 CALL_ARG (ns);
986 CALL_ARG (type); 1019 CALL_ARG (type);
987 CALL_ARG_SV (newSVpv_utf8 (msg)); 1020 CALL_ARG_SV (newSVpv_utf8 (msg));
988 CALL_ARG (color); 1021 CALL_ARG (color);
989 CALL_CALL ("cf::client::send_msg", G_VOID); 1022 CALL_CALL (cv_cf_client_send_msg, G_VOID);
990 CALL_END; 1023 CALL_END;
991} 1024}
992 1025
993int 1026int
994cfperl_can_merge (object *ob1, object *ob2) 1027cfperl_can_merge (object *ob1, object *ob2)
996 int can; 1029 int can;
997 1030
998 CALL_BEGIN (2); 1031 CALL_BEGIN (2);
999 CALL_ARG (ob1); 1032 CALL_ARG (ob1);
1000 CALL_ARG (ob2); 1033 CALL_ARG (ob2);
1001 CALL_CALL ("cf::_can_merge", G_SCALAR); 1034 CALL_CALL (cv_cf__can_merge, G_SCALAR);
1002 can = count && SvTRUE (TOPs); 1035 can = count && SvTRUE (TOPs);
1003 CALL_END; 1036 CALL_END;
1004 1037
1005 return can; 1038 return can;
1039}
1040
1041void
1042cfperl_mapscript_activate (object *ob, int state, object *activator, object *originator)
1043{
1044 CALL_BEGIN (4);
1045 CALL_ARG (ob);
1046 CALL_ARG (state);
1047 CALL_ARG (activator);
1048 CALL_ARG (originator);
1049 CALL_CALL ("cf::mapscript::activate", G_VOID);
1050 CALL_END;
1006} 1051}
1007 1052
1008player * 1053player *
1009player::find (const char *name) 1054player::find (const char *name)
1010{ 1055{
1150 CALL_CALL ("cf::_log_backtrace", G_VOID); 1195 CALL_CALL ("cf::_log_backtrace", G_VOID);
1151 CALL_END; 1196 CALL_END;
1152#endif 1197#endif
1153} 1198}
1154 1199
1200bool
1201is_match_expr (const char *expr)
1202{
1203 return !strncmp (expr, "match ", sizeof ("match ") - 1);
1204}
1205
1206bool
1207match (const char *expr, object *ob, object *self, object *source, object *originator)
1208{
1209 if (!strncmp (expr, "match ", sizeof ("match ") - 1))
1210 expr += sizeof ("match ") - 1;
1211
1212 CALL_BEGIN (5);
1213 CALL_ARG (expr);
1214 CALL_ARG (ob);
1215 CALL_ARG (self);
1216 CALL_ARG (source);
1217 CALL_ARG (originator);
1218 CALL_CALL (cv_cf_match_match, G_SCALAR);
1219
1220 bool matched = count && SvTRUE (TOPs);
1221
1222 CALL_END;
1223
1224 return matched;
1225}
1226
1227object *
1228match_one (const char *expr, object *ob, object *self, object *source, object *originator)
1229{
1230 if (!strncmp (expr, "match ", sizeof ("match ") - 1))
1231 expr += sizeof ("match ") - 1;
1232
1233 CALL_BEGIN (5);
1234 CALL_ARG (expr);
1235 CALL_ARG (ob);
1236 CALL_ARG (self);
1237 CALL_ARG (source);
1238 CALL_ARG (originator);
1239 CALL_CALL (cv_cf_match_match, G_ARRAY);
1240
1241 object *one = 0;
1242
1243 if (count)
1244 sv_to (TOPs, one);
1245
1246 CALL_END;
1247
1248 return one;
1249}
1250
1155///////////////////////////////////////////////////////////////////////////// 1251/////////////////////////////////////////////////////////////////////////////
1156 1252
1157struct EVAPI *evapi::GEVAPI; 1253struct EVAPI *evapi::GEVAPI;
1158struct CoroAPI *coroapi::GCoroAPI; 1254struct CoroAPI *coroapi::GCoroAPI;
1159 1255
1256void
1160void coroapi::do_cede_to_tick () 1257coroapi::do_cede_to_tick ()
1161{ 1258{
1162 cede_pending = 0; 1259 cede_pending = 0;
1163 cede (); 1260 cede ();
1164} 1261}
1165 1262
1189 ev_io_set ((ev_io *)this, fd, events); 1286 ev_io_set ((ev_io *)this, fd, events);
1190 if (active) start (); 1287 if (active) start ();
1191 } 1288 }
1192} 1289}
1193 1290
1194void 1291static void
1195_connect_to_perl () 1292_connect_to_perl_1 ()
1196{ 1293{
1197 stash_cf = gv_stashpv ("cf", 1); 1294 stash_cf = gv_stashpv ("cf", 1);
1198 1295
1199 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1296 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1200 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); 1297 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1);
1219 cb_client = get_av ("cf::CB_CLIENT", 1); 1316 cb_client = get_av ("cf::CB_CLIENT", 1);
1220 cb_type = get_av ("cf::CB_TYPE" , 1); 1317 cb_type = get_av ("cf::CB_TYPE" , 1);
1221 cb_map = get_av ("cf::CB_MAP" , 1); 1318 cb_map = get_av ("cf::CB_MAP" , 1);
1222} 1319}
1223 1320
1321static void
1322_connect_to_perl_2 ()
1323{
1324 cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke);
1325 cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge);
1326 cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg);
1327 cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick);
1328 cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match);
1329}
1330
1224MODULE = cf PACKAGE = cf PREFIX = cf_ 1331MODULE = cf PACKAGE = cf PREFIX = cf_
1225 1332
1226BOOT: 1333BOOT:
1227{ 1334{
1228 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; 1335 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1229 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1336 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1230 1337
1231 _connect_to_perl (); 1338 _connect_to_perl_1 ();
1232 1339
1233 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1340 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1234 1341
1235 //{ 1342 //{
1236 // require_pv ("Time::HiRes"); 1343 // require_pv ("Time::HiRes");
1280 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR) 1387 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR)
1281 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH) 1388 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH)
1282 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL) 1389 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL)
1283 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK) 1390 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK)
1284 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON) 1391 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON)
1285 const_iv (CF_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN) 1392 const_iv (T_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN)
1286 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT) 1393 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT)
1287 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED) 1394 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED)
1288 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE) 1395 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE)
1289 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) 1396 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON)
1290 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1397 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1291 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) 1398 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE)
1292 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) 1399 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE)
1293 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) 1400 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1401 const_iv (MAPSCRIPT) const_iv (SAFE_GROUND)
1294 1402
1295 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) 1403 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1296 1404
1297 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1405 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1298 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) 1406 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
1507 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1615 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1508 av_push (event, newSViv (eiv->klass)); 1616 av_push (event, newSViv (eiv->klass));
1509 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1617 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1510 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1618 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1511 } 1619 }
1620
1621 // used by autogenerated BOOT sections from genacc
1622 av_reflect = get_av ("cf::REFLECT", 1);
1512} 1623}
1513 1624
1514void _gv_clear (SV *gv) 1625void _gv_clear (SV *gv)
1515 CODE: 1626 CODE:
1516 assert (SvTYPE (gv) == SVt_PVGV); 1627 assert (SvTYPE (gv) == SVt_PVGV);
1523 f (GvGP (gv)->gp_cv); 1634 f (GvGP (gv)->gp_cv);
1524 GvCVGEN (gv) = 0; 1635 GvCVGEN (gv) = 0;
1525 GvMULTI_off (gv); 1636 GvMULTI_off (gv);
1526# undef f 1637# undef f
1527 1638
1528void _connect_to_perl () 1639void _connect_to_perl_1 ()
1640
1641void _connect_to_perl_2 ()
1529 1642
1530void _recalc_want () 1643void _recalc_want ()
1531 1644
1532# not used by default anymore 1645# not used by default anymore
1533void _global_reattach () 1646void _global_reattach ()
2051 CODE: 2164 CODE:
2052 player_apply_below (op); 2165 player_apply_below (op);
2053 2166
2054int cast_heal (object *op, object *caster, object *spell, int dir = 0) 2167int cast_heal (object *op, object *caster, object *spell, int dir = 0)
2055 2168
2169int casting_level (object *caster, object *spell)
2170
2056int pay_item (object *op, object *buyer) 2171int pay_item (object *op, object *buyer)
2057 CODE: 2172 CODE:
2058 RETVAL = pay_for_item (op, buyer); 2173 RETVAL = pay_for_item (op, buyer);
2059 OUTPUT: RETVAL 2174 OUTPUT: RETVAL
2060 2175
2104 2219
2105int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2220int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2106 2221
2107int calc_skill_exp (object *who, object *op, object *skill); 2222int calc_skill_exp (object *who, object *op, object *skill);
2108 2223
2109void push_button (object *op); 2224void push_button (object *op, object *originator);
2110 2225
2111void use_trigger (object *op); 2226void use_trigger (object *op, object *originator);
2112
2113void add_button_link (object *button, maptile *map, int connected);
2114
2115void remove_button_link (object *op);
2116 2227
2117void handle_apply_yield (object *op); 2228void handle_apply_yield (object *op);
2229
2230int convert_item (object *item, object *converter);
2118 2231
2119 2232
2120MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2233MODULE = cf PACKAGE = cf::object PREFIX = cf_
2121 2234
2122# no clean way to get an object from an archetype - stupid idiotic 2235# no clean way to get an object from an archetype - stupid idiotic
2135object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) 2248object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
2136 PROTOTYPE: $$$$$$ 2249 PROTOTYPE: $$$$$$
2137 CODE: 2250 CODE:
2138{ 2251{
2139 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y); 2252 RETVAL = insert_ob_in_map_at (ob, where, orig, flag, x, y);
2253
2254 if (RETVAL->destroyed ())
2255 RETVAL = 0;
2140} 2256}
2141 2257
2142shstr 2258shstr
2143object::kv_get (shstr key) 2259object::kv_get (shstr key)
2144 2260
2328void 2444void
2329adjust_daylight () 2445adjust_daylight ()
2330 CODE: 2446 CODE:
2331 maptile::adjust_daylight (); 2447 maptile::adjust_daylight ();
2332 2448
2449int
2450outdoor_darkness (int darkness = 0)
2451 CODE:
2452 RETVAL = maptile::outdoor_darkness;
2453 if (items)
2454 maptile::outdoor_darkness = darkness;
2455 OUTPUT:
2456 RETVAL
2457
2333void 2458void
2334maptile::instantiate () 2459maptile::instantiate ()
2335 2460
2336maptile *new () 2461maptile *new ()
2337 PROTOTYPE: 2462 PROTOTYPE:
2445 } 2570 }
2446 2571
2447int out_of_map (maptile *map, int x, int y) 2572int out_of_map (maptile *map, int x, int y)
2448 2573
2449void 2574void
2450trigger (maptile *map, long connection, bool state = true) 2575find_link (maptile *map, shstr_tmp connection)
2451 CODE:
2452 activate_connection (map, connection, state);
2453
2454void
2455get_connection (maptile *map, long connection)
2456 PPCODE: 2576 PPCODE:
2457 oblinkpt *obp = get_connection_links (map, connection); 2577 if (oblinkpt *obp = map->find_link (connection))
2458 if (obp)
2459 for (objectlink *ol = obp->link; ol; ol = ol->next) 2578 for (objectlink *ol = obp->link; ol; ol = ol->next)
2460 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); 2579 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2461 2580
2462void 2581void
2463get_map_flags (maptile *map, int x, int y) 2582get_map_flags (maptile *map, int x, int y)
2552 case 6: RETVAL = newSVuv (ms.move_on ); break; 2671 case 6: RETVAL = newSVuv (ms.move_on ); break;
2553 case 7: RETVAL = newSVuv (ms.move_off ); break; 2672 case 7: RETVAL = newSVuv (ms.move_off ); break;
2554 } 2673 }
2555} 2674}
2556 OUTPUT: RETVAL 2675 OUTPUT: RETVAL
2557
2558void fix_walls (maptile *map, int x, int y)
2559
2560void fix_walls_around (maptile *map, int x, int y)
2561 2676
2562# worst xs function of my life 2677# worst xs function of my life
2563bool 2678bool
2564_create_random_map (\ 2679_create_random_map (\
2565 maptile *self,\ 2680 maptile *self,\
2693 PROTOTYPE: $ 2808 PROTOTYPE: $
2694 CODE: 2809 CODE:
2695 RETVAL = region::find (name); 2810 RETVAL = region::find (name);
2696 OUTPUT: RETVAL 2811 OUTPUT: RETVAL
2697 2812
2698region *find_fuzzy (utf8_string name)
2699 PROTOTYPE: $
2700 CODE:
2701 RETVAL = region::find_fuzzy (name);
2702 OUTPUT: RETVAL
2703
2704int specificity (region *rgn) 2813int specificity (region *rgn)
2705 CODE: 2814 CODE:
2706 RETVAL = 0; 2815 RETVAL = 0;
2707 while (rgn = rgn->parent) 2816 while (rgn = rgn->parent)
2708 RETVAL++; 2817 RETVAL++;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines