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.307 by root, Sun Nov 16 03:52:13 2008 UTC vs.
Revision 1.328 by root, Tue Nov 3 22:57:06 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{
1074maptile::do_load_sync () 1119maptile::do_load_sync ()
1075{ 1120{
1076 CALL_BEGIN (1); 1121 CALL_BEGIN (1);
1077 CALL_ARG (this); 1122 CALL_ARG (this);
1078 CALL_CALL ("cf::map::do_load_sync", G_SCALAR); 1123 CALL_CALL ("cf::map::do_load_sync", G_SCALAR);
1079 CALL_END;
1080}
1081
1082void
1083maptile::change_all_map_light (int change)
1084{
1085 CALL_BEGIN (1);
1086 CALL_ARG (change);
1087 CALL_CALL ("cf::map::change_all_map_light", G_VOID);
1088 CALL_END; 1124 CALL_END;
1089} 1125}
1090 1126
1091void 1127void
1092object::enter_exit (object *exit) 1128object::enter_exit (object *exit)
1159 CALL_CALL ("cf::_log_backtrace", G_VOID); 1195 CALL_CALL ("cf::_log_backtrace", G_VOID);
1160 CALL_END; 1196 CALL_END;
1161#endif 1197#endif
1162} 1198}
1163 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
1164///////////////////////////////////////////////////////////////////////////// 1227/////////////////////////////////////////////////////////////////////////////
1165 1228
1166struct EVAPI *evapi::GEVAPI; 1229struct EVAPI *evapi::GEVAPI;
1167struct CoroAPI *coroapi::GCoroAPI; 1230struct CoroAPI *coroapi::GCoroAPI;
1168 1231
1232void
1169void coroapi::do_cede_to_tick () 1233coroapi::do_cede_to_tick ()
1170{ 1234{
1171 cede_pending = 0; 1235 cede_pending = 0;
1172 cede (); 1236 cede ();
1173} 1237}
1174 1238
1198 ev_io_set ((ev_io *)this, fd, events); 1262 ev_io_set ((ev_io *)this, fd, events);
1199 if (active) start (); 1263 if (active) start ();
1200 } 1264 }
1201} 1265}
1202 1266
1203void 1267static void
1204_connect_to_perl () 1268_connect_to_perl_1 ()
1205{ 1269{
1206 stash_cf = gv_stashpv ("cf", 1); 1270 stash_cf = gv_stashpv ("cf", 1);
1207 1271
1208 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1272 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1209 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1); 1273 stash_cf_object_player_wrap = gv_stashpv ("cf::object::player::wrap", 1);
1228 cb_client = get_av ("cf::CB_CLIENT", 1); 1292 cb_client = get_av ("cf::CB_CLIENT", 1);
1229 cb_type = get_av ("cf::CB_TYPE" , 1); 1293 cb_type = get_av ("cf::CB_TYPE" , 1);
1230 cb_map = get_av ("cf::CB_MAP" , 1); 1294 cb_map = get_av ("cf::CB_MAP" , 1);
1231} 1295}
1232 1296
1297static void
1298_connect_to_perl_2 ()
1299{
1300 cv_cf_do_invoke = (SV *)get_cv ("cf::do_invoke" , 0); assert (cv_cf_do_invoke);
1301 cv_cf__can_merge = (SV *)get_cv ("cf::_can_merge" , 0); assert (cv_cf__can_merge);
1302 cv_cf_client_send_msg = (SV *)get_cv ("cf::client::send_msg", 0); assert (cv_cf_client_send_msg);
1303 cv_cf_tick = (SV *)get_cv ("cf::tick" , 0); assert (cv_cf_tick);
1304 cv_cf_match_match = (SV *)get_cv ("cf::match::match" , 0); assert (cv_cf_match_match);
1305}
1306
1233MODULE = cf PACKAGE = cf PREFIX = cf_ 1307MODULE = cf PACKAGE = cf PREFIX = cf_
1234 1308
1235BOOT: 1309BOOT:
1236{ 1310{
1237 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; 1311 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1238 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1312 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1239 1313
1240 _connect_to_perl (); 1314 _connect_to_perl_1 ();
1241 1315
1242 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1316 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1243 1317
1244 //{ 1318 //{
1245 // require_pv ("Time::HiRes"); 1319 // require_pv ("Time::HiRes");
1289 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR) 1363 const_iv (MOOD_FLOOR) const_iv (EXIT) const_iv (ENCOUNTER) const_iv (SHOP_FLOOR)
1290 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH) 1364 const_iv (SHOP_MAT) const_iv (RING) const_iv (FLOOR) const_iv (FLESH)
1291 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL) 1365 const_iv (INORGANIC) const_iv (SKILL_TOOL) const_iv (LIGHTER) const_iv (BUILDABLE_WALL)
1292 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK) 1366 const_iv (MISC_OBJECT) const_iv (LAMP) const_iv (DUPLICATOR) const_iv (SPELLBOOK)
1293 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON) 1367 const_iv (CLOAK) const_iv (SPINNER) const_iv (GATE) const_iv (BUTTON)
1294 const_iv (CF_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN) 1368 const_iv (T_HANDLE) const_iv (HOLE) const_iv (TRAPDOOR) const_iv (SIGN)
1295 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT) 1369 const_iv (BOOTS) const_iv (GLOVES) const_iv (SPELL) const_iv (SPELL_EFFECT)
1296 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED) 1370 const_iv (CONVERTER) const_iv (BRACERS) const_iv (POISONING) const_iv (SAVEBED)
1297 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE) 1371 const_iv (WAND) const_iv (SCROLL) const_iv (DIRECTOR) const_iv (GIRDLE)
1298 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON) 1372 const_iv (FORCE) const_iv (POTION_EFFECT) const_iv (EVENT_CONNECTOR) const_iv (CLOSE_CON)
1299 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1373 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1300 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) 1374 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE)
1301 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) 1375 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE)
1302 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) 1376 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1377 const_iv (MAPSCRIPT) const_iv (SAFE_GROUND)
1303 1378
1304 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES) 1379 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1305 1380
1306 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1381 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1307 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) 1382 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
1339 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED) 1414 const_iv (FLAG_USE_ROD) const_iv (FLAG_USE_HORN) const_iv (FLAG_MAKE_INVIS) const_iv (FLAG_INV_LOCKED)
1340 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON) 1415 const_iv (FLAG_IS_WOODED) const_iv (FLAG_IS_HILLY) const_iv (FLAG_READY_SKILL) const_iv (FLAG_READY_WEAPON)
1341 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON) 1416 const_iv (FLAG_NO_SKILL_IDENT) const_iv (FLAG_BLIND) const_iv (FLAG_SEE_IN_DARK) const_iv (FLAG_IS_CAULDRON)
1342 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK) 1417 const_iv (FLAG_NO_STEAL) const_iv (FLAG_ONE_HIT) const_iv (FLAG_DEBUG) const_iv (FLAG_BERSERK)
1343 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL) 1418 const_iv (FLAG_NEUTRAL) const_iv (FLAG_NO_ATTACK) const_iv (FLAG_NO_DAMAGE) const_iv (FLAG_OBJ_ORIGINAL)
1344 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) 1419 const_iv (FLAG_ACTIVATE_ON_PUSH) const_iv (FLAG_ACTIVATE_ON_RELEASE) const_iv (FLAG_IS_WATER) const_iv (FLAG_WIZLOOK)
1345 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE) 1420 const_iv (FLAG_CONTENT_ON_GEN) const_iv (FLAG_IS_A_TEMPLATE) const_iv (FLAG_IS_BUILDABLE)
1346 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE) 1421 const_iv (FLAG_DESTROY_ON_DEATH) const_iv (FLAG_NO_MAP_SAVE)
1347 1422
1348 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED) 1423 const_iv (NDI_BLACK) const_iv (NDI_WHITE) const_iv (NDI_NAVY) const_iv (NDI_RED)
1349 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN) 1424 const_iv (NDI_ORANGE) const_iv (NDI_BLUE) const_iv (NDI_DK_ORANGE) const_iv (NDI_GREEN)
1516 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1591 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1517 av_push (event, newSViv (eiv->klass)); 1592 av_push (event, newSViv (eiv->klass));
1518 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1593 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1519 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1594 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1520 } 1595 }
1596
1597 // used by autogenerated BOOT sections from genacc
1598 av_reflect = get_av ("cf::REFLECT", 1);
1521} 1599}
1522 1600
1523void _gv_clear (SV *gv) 1601void _gv_clear (SV *gv)
1524 CODE: 1602 CODE:
1525 assert (SvTYPE (gv) == SVt_PVGV); 1603 assert (SvTYPE (gv) == SVt_PVGV);
1532 f (GvGP (gv)->gp_cv); 1610 f (GvGP (gv)->gp_cv);
1533 GvCVGEN (gv) = 0; 1611 GvCVGEN (gv) = 0;
1534 GvMULTI_off (gv); 1612 GvMULTI_off (gv);
1535# undef f 1613# undef f
1536 1614
1537void _connect_to_perl () 1615void _connect_to_perl_1 ()
1616
1617void _connect_to_perl_2 ()
1538 1618
1539void _recalc_want () 1619void _recalc_want ()
1540 1620
1541# not used by default anymore 1621# not used by default anymore
1542void _global_reattach () 1622void _global_reattach ()
1599void init_experience () 1679void init_experience ()
1600 1680
1601void init_attackmess () 1681void init_attackmess ()
1602 1682
1603void init_dynamic () 1683void init_dynamic ()
1604
1605void init_block ()
1606 1684
1607void load_settings () 1685void load_settings ()
1608 1686
1609void load_materials () 1687void load_materials ()
1610 1688
1795 PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks))); 1873 PUSHs (sv_2mortal (newSVpv ("fsmblks" , 0))); PUSHs (sv_2mortal (newSViv (mai.fsmblks)));
1796 PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks))); 1874 PUSHs (sv_2mortal (newSVpv ("uordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.uordblks)));
1797 PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks))); 1875 PUSHs (sv_2mortal (newSVpv ("fordblks", 0))); PUSHs (sv_2mortal (newSViv (mai.fordblks)));
1798 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost))); 1876 PUSHs (sv_2mortal (newSVpv ("keepcost", 0))); PUSHs (sv_2mortal (newSViv (mai.keepcost)));
1799#endif 1877#endif
1800 EXTEND (SP, 2*2); 1878 EXTEND (SP, 5*2);
1801 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc))); 1879 PUSHs (sv_2mortal (newSVpv ("slice_alloc", 0))); PUSHs (sv_2mortal (newSVuv (slice_alloc)));
1802 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc))); 1880 PUSHs (sv_2mortal (newSVpv ("shstr_alloc", 0))); PUSHs (sv_2mortal (newSVuv (shstr_alloc)));
1803 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object)))); 1881 PUSHs (sv_2mortal (newSVpv ("objects" , 0))); PUSHs (sv_2mortal (newSVuv (objects.size () * sizeof (object))));
1882 PUSHs (sv_2mortal (newSVpv ("sv_count" , 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_count)));
1883 PUSHs (sv_2mortal (newSVpv ("sv_objcount", 0))); PUSHs (sv_2mortal (newSVuv (PL_sv_objcount)));
1804} 1884}
1805 1885
1806int find_animation (utf8_string text) 1886int find_animation (utf8_string text)
1807 PROTOTYPE: $ 1887 PROTOTYPE: $
1808 1888
2113 2193
2114int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL) 2194int kill_object (object *op, int dam = 0, object *hitter = 0, int type = AT_PHYSICAL)
2115 2195
2116int calc_skill_exp (object *who, object *op, object *skill); 2196int calc_skill_exp (object *who, object *op, object *skill);
2117 2197
2118void push_button (object *op); 2198void push_button (object *op, object *originator);
2119 2199
2120void use_trigger (object *op); 2200void use_trigger (object *op, object *originator);
2121
2122void add_button_link (object *button, maptile *map, int connected);
2123
2124void remove_button_link (object *op);
2125 2201
2126void handle_apply_yield (object *op); 2202void handle_apply_yield (object *op);
2203
2204int convert_item (object *item, object *converter);
2127 2205
2128 2206
2129MODULE = cf PACKAGE = cf::object PREFIX = cf_ 2207MODULE = cf PACKAGE = cf::object PREFIX = cf_
2130 2208
2131# no clean way to get an object from an archetype - stupid idiotic 2209# no clean way to get an object from an archetype - stupid idiotic
2248 pl->ob->stats.hp = pl->ob->stats.maxhp; 2326 pl->ob->stats.hp = pl->ob->stats.maxhp;
2249 pl->ob->stats.sp = pl->ob->stats.maxsp; 2327 pl->ob->stats.sp = pl->ob->stats.maxsp;
2250 pl->ob->stats.grace = pl->ob->stats.maxgrace; 2328 pl->ob->stats.grace = pl->ob->stats.maxgrace;
2251 pl->orig_stats = pl->ob->stats; 2329 pl->orig_stats = pl->ob->stats;
2252 2330
2253void clear_los (player *pl)
2254
2255# should only be temporary 2331# should only be temporary
2256void esrv_new_player (player *pl) 2332void esrv_new_player (player *pl)
2257 2333
2334#d# TODO: replace by blocked_los accessor, fix code using this
2258bool 2335bool
2259cell_visible (player *pl, int dx, int dy) 2336cell_visible (player *pl, int dx, int dy)
2260 CODE: 2337 CODE:
2261 RETVAL = FABS (dx) <= pl->ns->mapx / 2 && FABS (dy) <= pl->ns->mapy / 2 2338 RETVAL = pl->blocked_los (dx, dy) != LOS_BLOCKED;
2262 && !pl->blocked_los [dx + pl->ns->mapx / 2][dy + pl->ns->mapy / 2];
2263 OUTPUT: 2339 OUTPUT:
2264 RETVAL 2340 RETVAL
2265 2341
2266void 2342void
2267send (player *pl, SV *packet) 2343send (player *pl, SV *packet)
2335} 2411}
2336 2412
2337INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h | 2413INCLUDE: $PERL $srcdir/genacc maptile ../include/map.h |
2338 2414
2339void 2415void
2416adjust_daylight ()
2417 CODE:
2418 maptile::adjust_daylight ();
2419
2420int
2421outdoor_darkness (int darkness = 0)
2422 CODE:
2423 RETVAL = maptile::outdoor_darkness;
2424 if (items)
2425 maptile::outdoor_darkness = darkness;
2426 OUTPUT:
2427 RETVAL
2428
2429void
2340maptile::instantiate () 2430maptile::instantiate ()
2341 2431
2342maptile *new () 2432maptile *new ()
2343 PROTOTYPE: 2433 PROTOTYPE:
2344 CODE: 2434 CODE:
2451 } 2541 }
2452 2542
2453int out_of_map (maptile *map, int x, int y) 2543int out_of_map (maptile *map, int x, int y)
2454 2544
2455void 2545void
2456trigger (maptile *map, long connection, bool state = true) 2546find_link (maptile *map, shstr_tmp connection)
2457 CODE:
2458 activate_connection (map, connection, state);
2459
2460void
2461get_connection (maptile *map, long connection)
2462 PPCODE: 2547 PPCODE:
2463 oblinkpt *obp = get_connection_links (map, connection); 2548 if (oblinkpt *obp = map->find_link (connection))
2464 if (obp)
2465 for (objectlink *ol = obp->link; ol; ol = ol->next) 2549 for (objectlink *ol = obp->link; ol; ol = ol->next)
2466 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob))); 2550 XPUSHs (sv_2mortal (to_sv ((object *)ol->ob)));
2467 2551
2468void 2552void
2469get_map_flags (maptile *map, int x, int y) 2553get_map_flags (maptile *map, int x, int y)
2523 for (object *o = nmap->at (nx, ny).bot; o; o = o->above) 2607 for (object *o = nmap->at (nx, ny).bot; o; o = o->above)
2524 XPUSHs (sv_2mortal (to_sv (o))); 2608 XPUSHs (sv_2mortal (to_sv (o)));
2525} 2609}
2526 2610
2527SV * 2611SV *
2528bot_at (maptile *obj, unsigned int x, unsigned int y) 2612bot_at (maptile *map, unsigned int x, unsigned int y)
2529 PROTOTYPE: $$$ 2613 PROTOTYPE: $$$
2530 ALIAS: 2614 ALIAS:
2531 top_at = 1 2615 top_at = 1
2532 flags_at = 2 2616 flags_at = 2
2533 light_at = 3 2617 light_at = 3
2534 move_block_at = 4 2618 move_block_at = 4
2535 move_slow_at = 5 2619 move_slow_at = 5
2536 move_on_at = 6 2620 move_on_at = 6
2537 move_off_at = 7 2621 move_off_at = 7
2538 INIT:
2539 if (x >= obj->width || y >= obj->height) XSRETURN_UNDEF;
2540 CODE: 2622 CODE:
2623{
2624 sint16 nx = x;
2625 sint16 ny = y;
2626
2627 if (!xy_normalise (map, nx, ny))
2628 XSRETURN_UNDEF;
2629
2630 mapspace &ms = map->at (nx, ny);
2631
2632 ms.update ();
2633
2541 switch (ix) 2634 switch (ix)
2542 { 2635 {
2543 case 0: RETVAL = to_sv (GET_MAP_OB (obj, x, y)); break; 2636 case 0: RETVAL = to_sv (ms.bot ); break;
2544 case 1: RETVAL = to_sv (GET_MAP_TOP (obj, x, y)); break; 2637 case 1: RETVAL = to_sv (ms.top ); break;
2545 case 2: RETVAL = newSVuv (GET_MAP_FLAGS (obj, x, y)); break; 2638 case 2: RETVAL = newSVuv (ms.flags_ ); break;
2546 case 3: RETVAL = newSViv (GET_MAP_LIGHT (obj, x, y)); break; 2639 case 3: RETVAL = newSViv (ms.light ); break;
2547 case 4: RETVAL = newSVuv (GET_MAP_MOVE_BLOCK (obj, x, y)); break; 2640 case 4: RETVAL = newSVuv (ms.move_block); break;
2548 case 5: RETVAL = newSVuv (GET_MAP_MOVE_SLOW (obj, x, y)); break; 2641 case 5: RETVAL = newSVuv (ms.move_slow ); break;
2549 case 6: RETVAL = newSVuv (GET_MAP_MOVE_ON (obj, x, y)); break; 2642 case 6: RETVAL = newSVuv (ms.move_on ); break;
2550 case 7: RETVAL = newSVuv (GET_MAP_MOVE_OFF (obj, x, y)); break; 2643 case 7: RETVAL = newSVuv (ms.move_off ); break;
2551 } 2644 }
2645}
2552 OUTPUT: RETVAL 2646 OUTPUT: RETVAL
2553
2554void fix_walls (maptile *map, int x, int y)
2555
2556void fix_walls_around (maptile *map, int x, int y)
2557 2647
2558# worst xs function of my life 2648# worst xs function of my life
2559bool 2649bool
2560_create_random_map (\ 2650_create_random_map (\
2561 maptile *self,\ 2651 maptile *self,\
2689 PROTOTYPE: $ 2779 PROTOTYPE: $
2690 CODE: 2780 CODE:
2691 RETVAL = region::find (name); 2781 RETVAL = region::find (name);
2692 OUTPUT: RETVAL 2782 OUTPUT: RETVAL
2693 2783
2694region *find_fuzzy (utf8_string name)
2695 PROTOTYPE: $
2696 CODE:
2697 RETVAL = region::find_fuzzy (name);
2698 OUTPUT: RETVAL
2699
2700int specificity (region *rgn) 2784int specificity (region *rgn)
2701 CODE: 2785 CODE:
2702 RETVAL = 0; 2786 RETVAL = 0;
2703 while (rgn = rgn->parent) 2787 while (rgn = rgn->parent)
2704 RETVAL++; 2788 RETVAL++;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines