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.322 by root, Sun Oct 11 18:18:04 2009 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"
88 *stash_cf_client_wrap, 88 *stash_cf_client_wrap,
89 *stash_cf_arch_wrap, 89 *stash_cf_arch_wrap,
90 *stash_cf_party_wrap, 90 *stash_cf_party_wrap,
91 *stash_cf_region_wrap, 91 *stash_cf_region_wrap,
92 *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;
93 100
94#ifndef newSVpv_utf8 101#ifndef newSVpv_utf8
95static inline SV * 102static inline SV *
96newSVpv_utf8 (const char *s) 103newSVpv_utf8 (const char *s)
97{ 104{
919 XPUSHs (sv_2mortal (newSVdt_va (ap, dt))); 926 XPUSHs (sv_2mortal (newSVdt_va (ap, dt)));
920 } 927 }
921 928
922 va_end (ap); 929 va_end (ap);
923 930
924 CALL_CALL ("cf::do_invoke", G_SCALAR); 931 CALL_CALL (cv_cf_do_invoke, G_SCALAR);
925 count = count > 0 ? POPi : 0; 932 count = count > 0 ? POPi : 0;
926 933
927 CALL_END; 934 CALL_END;
928 935
929 return count; 936 return count;
970 977
971 dSP; 978 dSP;
972 979
973 PUSHMARK (SP); 980 PUSHMARK (SP);
974 PUTBACK; 981 PUTBACK;
975 call_pv ("cf::tick", G_DISCARD | G_VOID); 982 call_pvsv (cv_cf_tick, G_DISCARD | G_VOID);
976 983
977 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);
978} 985}
979 986
980void 987void
1010 CALL_BEGIN (4); 1017 CALL_BEGIN (4);
1011 CALL_ARG (ns); 1018 CALL_ARG (ns);
1012 CALL_ARG (type); 1019 CALL_ARG (type);
1013 CALL_ARG_SV (newSVpv_utf8 (msg)); 1020 CALL_ARG_SV (newSVpv_utf8 (msg));
1014 CALL_ARG (color); 1021 CALL_ARG (color);
1015 CALL_CALL ("cf::client::send_msg", G_VOID); 1022 CALL_CALL (cv_cf_client_send_msg, G_VOID);
1016 CALL_END; 1023 CALL_END;
1017} 1024}
1018 1025
1019int 1026int
1020cfperl_can_merge (object *ob1, object *ob2) 1027cfperl_can_merge (object *ob1, object *ob2)
1022 int can; 1029 int can;
1023 1030
1024 CALL_BEGIN (2); 1031 CALL_BEGIN (2);
1025 CALL_ARG (ob1); 1032 CALL_ARG (ob1);
1026 CALL_ARG (ob2); 1033 CALL_ARG (ob2);
1027 CALL_CALL ("cf::_can_merge", G_SCALAR); 1034 CALL_CALL (cv_cf__can_merge, G_SCALAR);
1028 can = count && SvTRUE (TOPs); 1035 can = count && SvTRUE (TOPs);
1029 CALL_END; 1036 CALL_END;
1030 1037
1031 return can; 1038 return can;
1032} 1039}
1188 CALL_CALL ("cf::_log_backtrace", G_VOID); 1195 CALL_CALL ("cf::_log_backtrace", G_VOID);
1189 CALL_END; 1196 CALL_END;
1190#endif 1197#endif
1191} 1198}
1192 1199
1200bool
1193bool is_match_expr (const char *expr) 1201is_match_expr (const char *expr)
1194{ 1202{
1195 return !strncmp (expr, "match ", sizeof ("match ") - 1); 1203 return !strncmp (expr, "match ", sizeof ("match ") - 1);
1196} 1204}
1197 1205
1206bool
1198bool match (const char *expr, object *ob, object *self, object *source, object *originator) 1207match (const char *expr, object *ob, object *self, object *source, object *originator)
1199{ 1208{
1200 bool matched; 1209 if (!strncmp (expr, "match ", sizeof ("match ") - 1))
1210 expr += sizeof ("match ") - 1;
1201 1211
1202 CALL_BEGIN (5); 1212 CALL_BEGIN (5);
1203 CALL_ARG (expr); 1213 CALL_ARG (expr);
1204 CALL_ARG (ob); 1214 CALL_ARG (ob);
1205 CALL_ARG (self); 1215 CALL_ARG (self);
1206 CALL_ARG (source); 1216 CALL_ARG (source);
1207 CALL_ARG (originator); 1217 CALL_ARG (originator);
1208 CALL_CALL ("cf::match::match", G_SCALAR); 1218 CALL_CALL (cv_cf_match_match, G_SCALAR);
1209 1219
1210 matched = count && SvTRUE (POPs); 1220 bool matched = count && SvTRUE (TOPs);
1211 1221
1212 CALL_END; 1222 CALL_END;
1213 1223
1214 return matched; 1224 return matched;
1215} 1225}
1253 if (active) start (); 1263 if (active) start ();
1254 } 1264 }
1255} 1265}
1256 1266
1257static void 1267static void
1258_connect_to_perl () 1268_connect_to_perl_1 ()
1259{ 1269{
1260 stash_cf = gv_stashpv ("cf", 1); 1270 stash_cf = gv_stashpv ("cf", 1);
1261 1271
1262 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1); 1272 stash_cf_object_wrap = gv_stashpv ("cf::object::wrap", 1);
1263 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);
1280 cb_object = get_av ("cf::CB_OBJECT", 1); 1290 cb_object = get_av ("cf::CB_OBJECT", 1);
1281 cb_player = get_av ("cf::CB_PLAYER", 1); 1291 cb_player = get_av ("cf::CB_PLAYER", 1);
1282 cb_client = get_av ("cf::CB_CLIENT", 1); 1292 cb_client = get_av ("cf::CB_CLIENT", 1);
1283 cb_type = get_av ("cf::CB_TYPE" , 1); 1293 cb_type = get_av ("cf::CB_TYPE" , 1);
1284 cb_map = get_av ("cf::CB_MAP" , 1); 1294 cb_map = get_av ("cf::CB_MAP" , 1);
1295}
1285 1296
1286 av_reflect = get_av ("cf::REFLECT" , 1); 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);
1287} 1305}
1288 1306
1289MODULE = cf PACKAGE = cf PREFIX = cf_ 1307MODULE = cf PACKAGE = cf PREFIX = cf_
1290 1308
1291BOOT: 1309BOOT:
1292{ 1310{
1293 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI; 1311 I_EV_API (PACKAGE); evapi::GEVAPI = GEVAPI;
1294 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI; 1312 I_CORO_API (PACKAGE); coroapi::GCoroAPI = GCoroAPI;
1295 1313
1296 _connect_to_perl (); 1314 _connect_to_perl_1 ();
1297 1315
1298 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1316 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1299 1317
1300 //{ 1318 //{
1301 // require_pv ("Time::HiRes"); 1319 // require_pv ("Time::HiRes");
1345 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)
1346 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)
1347 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)
1348 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)
1349 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)
1350 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)
1351 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)
1352 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)
1353 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)
1354 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)
1355 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)
1573 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0)); 1591 av_push (event, newSVpv ((char *)eiv->name + eiv->skip, 0));
1574 av_push (event, newSViv (eiv->klass)); 1592 av_push (event, newSViv (eiv->klass));
1575 av_store (av, eiv->iv, newRV_noinc ((SV *)event)); 1593 av_store (av, eiv->iv, newRV_noinc ((SV *)event));
1576 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv)); 1594 newCONSTSUB (stash_cf, (char *)eiv->name, newSViv (eiv->iv));
1577 } 1595 }
1596
1597 // used by autogenerated BOOT sections from genacc
1598 av_reflect = get_av ("cf::REFLECT", 1);
1578} 1599}
1579 1600
1580void _gv_clear (SV *gv) 1601void _gv_clear (SV *gv)
1581 CODE: 1602 CODE:
1582 assert (SvTYPE (gv) == SVt_PVGV); 1603 assert (SvTYPE (gv) == SVt_PVGV);
1589 f (GvGP (gv)->gp_cv); 1610 f (GvGP (gv)->gp_cv);
1590 GvCVGEN (gv) = 0; 1611 GvCVGEN (gv) = 0;
1591 GvMULTI_off (gv); 1612 GvMULTI_off (gv);
1592# undef f 1613# undef f
1593 1614
1594void _connect_to_perl () 1615void _connect_to_perl_1 ()
1616
1617void _connect_to_perl_2 ()
1595 1618
1596void _recalc_want () 1619void _recalc_want ()
1597 1620
1598# not used by default anymore 1621# not used by default anymore
1599void _global_reattach () 1622void _global_reattach ()
2619 case 6: RETVAL = newSVuv (ms.move_on ); break; 2642 case 6: RETVAL = newSVuv (ms.move_on ); break;
2620 case 7: RETVAL = newSVuv (ms.move_off ); break; 2643 case 7: RETVAL = newSVuv (ms.move_off ); break;
2621 } 2644 }
2622} 2645}
2623 OUTPUT: RETVAL 2646 OUTPUT: RETVAL
2624
2625void fix_walls (maptile *map, int x, int y)
2626
2627void fix_walls_around (maptile *map, int x, int y)
2628 2647
2629# worst xs function of my life 2648# worst xs function of my life
2630bool 2649bool
2631_create_random_map (\ 2650_create_random_map (\
2632 maptile *self,\ 2651 maptile *self,\

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines