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.320 by root, Thu Jul 16 21:42:56 2009 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
87 *stash_cf_client_wrap, 88 *stash_cf_client_wrap,
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;
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;
92 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{
918 XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); 926 XPUSHs (sv_2mortal (newSVdt_va (ap, dt)));
919 } 927 }
920 928
921 va_end (ap); 929 va_end (ap);
922 930
923 CALL_CALL ("cf::do_invoke", G_SCALAR); 931 CALL_CALL (cv_cf_do_invoke, G_SCALAR);
924 count = count > 0 ? POPi : 0; 932 count = count > 0 ? POPi : 0;
925 933
926 CALL_END; 934 CALL_END;
927 935
928 return count; 936 return count;
969 977
970 dSP; 978 dSP;
971 979
972 PUSHMARK (SP); 980 PUSHMARK (SP);
973 PUTBACK; 981 PUTBACK;
974 call_pv ("cf::tick", G_DISCARD | G_VOID); 982 call_pvsv (cv_cf_tick, G_DISCARD | G_VOID);
975 983
976 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);
977} 985}
978 986
979void 987void
1009 CALL_BEGIN (4); 1017 CALL_BEGIN (4);
1010 CALL_ARG (ns); 1018 CALL_ARG (ns);
1011 CALL_ARG (type); 1019 CALL_ARG (type);
1012 CALL_ARG_SV (newSVpv_utf8 (msg)); 1020 CALL_ARG_SV (newSVpv_utf8 (msg));
1013 CALL_ARG (color); 1021 CALL_ARG (color);
1014 CALL_CALL ("cf::client::send_msg", G_VOID); 1022 CALL_CALL (cv_cf_client_send_msg, G_VOID);
1015 CALL_END; 1023 CALL_END;
1016} 1024}
1017 1025
1018int 1026int
1019cfperl_can_merge (object *ob1, object *ob2) 1027cfperl_can_merge (object *ob1, object *ob2)
1021 int can; 1029 int can;
1022 1030
1023 CALL_BEGIN (2); 1031 CALL_BEGIN (2);
1024 CALL_ARG (ob1); 1032 CALL_ARG (ob1);
1025 CALL_ARG (ob2); 1033 CALL_ARG (ob2);
1026 CALL_CALL ("cf::_can_merge", G_SCALAR); 1034 CALL_CALL (cv_cf__can_merge, G_SCALAR);
1027 can = count && SvTRUE (TOPs); 1035 can = count && SvTRUE (TOPs);
1028 CALL_END; 1036 CALL_END;
1029 1037
1030 return can; 1038 return can;
1031} 1039}
1187 CALL_CALL ("cf::_log_backtrace", G_VOID); 1195 CALL_CALL ("cf::_log_backtrace", G_VOID);
1188 CALL_END; 1196 CALL_END;
1189#endif 1197#endif
1190} 1198}
1191 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
1192///////////////////////////////////////////////////////////////////////////// 1251/////////////////////////////////////////////////////////////////////////////
1193 1252
1194struct EVAPI *evapi::GEVAPI; 1253struct EVAPI *evapi::GEVAPI;
1195struct CoroAPI *coroapi::GCoroAPI; 1254struct CoroAPI *coroapi::GCoroAPI;
1196 1255
1228 if (active) start (); 1287 if (active) start ();
1229 } 1288 }
1230} 1289}
1231 1290
1232static void 1291static void
1233_connect_to_perl () 1292_connect_to_perl_1 ()
1234{ 1293{
1235 stash_cf = gv_stashpv ("cf", 1); 1294 stash_cf = gv_stashpv ("cf", 1);
1236 1295
1237 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1296 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1238 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);
1257 cb_client = get_av ("cf::CB_CLIENT", 1); 1316 cb_client = get_av ("cf::CB_CLIENT", 1);
1258 cb_type = get_av ("cf::CB_TYPE" , 1); 1317 cb_type = get_av ("cf::CB_TYPE" , 1);
1259 cb_map = get_av ("cf::CB_MAP" , 1); 1318 cb_map = get_av ("cf::CB_MAP" , 1);
1260} 1319}
1261 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
1262MODULE = cf PACKAGE = cf PREFIX = cf_ 1331MODULE = cf PACKAGE = cf PREFIX = cf_
1263 1332
1264BOOT: 1333BOOT:
1265{ 1334{
1266 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; 1335 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1267 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1336 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1268 1337
1269 _connect_to_perl (); 1338 _connect_to_perl_1 ();
1270 1339
1271 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1340 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1272 1341
1273 //{ 1342 //{
1274 // require_pv ("Time::HiRes"); 1343 // require_pv ("Time::HiRes");
1318 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)
1319 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)
1320 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)
1321 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)
1322 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)
1323 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)
1324 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)
1325 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)
1326 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)
1327 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)
1328 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)
1546 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1615 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1547 av_push (event, newSViv (eiv->klass)); 1616 av_push (event, newSViv (eiv->klass));
1548 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1617 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1549 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1618 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1550 } 1619 }
1620
1621 // used by autogenerated BOOT sections from genacc
1622 av_reflect = get_av ("cf::REFLECT", 1);
1551} 1623}
1552 1624
1553void _gv_clear (SV *gv) 1625void _gv_clear (SV *gv)
1554 CODE: 1626 CODE:
1555 assert (SvTYPE (gv) == SVt_PVGV); 1627 assert (SvTYPE (gv) == SVt_PVGV);
1562 f (GvGP (gv)->gp_cv); 1634 f (GvGP (gv)->gp_cv);
1563 GvCVGEN (gv) = 0; 1635 GvCVGEN (gv) = 0;
1564 GvMULTI_off (gv); 1636 GvMULTI_off (gv);
1565# undef f 1637# undef f
1566 1638
1567void _connect_to_perl () 1639void _connect_to_perl_1 ()
1640
1641void _connect_to_perl_2 ()
1568 1642
1569void _recalc_want () 1643void _recalc_want ()
1570 1644
1571# not used by default anymore 1645# not used by default anymore
1572void _global_reattach () 1646void _global_reattach ()
2090 CODE: 2164 CODE:
2091 player_apply_below (op); 2165 player_apply_below (op);
2092 2166
2093int cast_heal (object *op, object *caster, object *spell, int dir = 0) 2167int cast_heal (object *op, object *caster, object *spell, int dir = 0)
2094 2168
2169int casting_level (object *caster, object *spell)
2170
2095int pay_item (object *op, object *buyer) 2171int pay_item (object *op, object *buyer)
2096 CODE: 2172 CODE:
2097 RETVAL = pay_for_item (op, buyer); 2173 RETVAL = pay_for_item (op, buyer);
2098 OUTPUT: RETVAL 2174 OUTPUT: RETVAL
2099 2175
2172object *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)
2173 PROTOTYPE: $$$$$$ 2249 PROTOTYPE: $$$$$$
2174 CODE: 2250 CODE:
2175{ 2251{
2176 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;
2177} 2256}
2178 2257
2179shstr 2258shstr
2180object::kv_get (shstr key) 2259object::kv_get (shstr key)
2181 2260
2592 case 6: RETVAL = newSVuv (ms.move_on ); break; 2671 case 6: RETVAL = newSVuv (ms.move_on ); break;
2593 case 7: RETVAL = newSVuv (ms.move_off ); break; 2672 case 7: RETVAL = newSVuv (ms.move_off ); break;
2594 } 2673 }
2595} 2674}
2596 OUTPUT: RETVAL 2675 OUTPUT: RETVAL
2597
2598void fix_walls (maptile *map, int x, int y)
2599
2600void fix_walls_around (maptile *map, int x, int y)
2601 2676
2602# worst xs function of my life 2677# worst xs function of my life
2603bool 2678bool
2604_create_random_map (\ 2679_create_random_map (\
2605 maptile *self,\ 2680 maptile *self,\

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines