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.204 by root, Mon Apr 30 04:25:30 2007 UTC vs.
Revision 1.220 by root, Sat Jun 9 22:54:03 2007 UTC

1/*****************************************************************************/
2/* CrossFire, A Multiplayer game for the X Window System */
3/*****************************************************************************/
4
5/* 1/*
6 * This code is placed under the GNU General Public Licence (GPL) 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
7 * 3 *
4 * Copyright (©) 2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
8 * Copyright (C) 2001-2005 by Chachkoff Yann 5 * Copyright (©) 2001-2005,2007 by Chachkoff Yann
9 * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de> 6 * Copyright (©) 2006,2007 by Marc Lehmann <cf@schmorp.de>
10 * 7 *
11 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
12 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
13 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
14 * (at your option) any later version. 11 * any later version.
15 * 12 *
16 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful, but
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * GNU General Public License for more details. 16 * for more details.
20 * 17 *
21 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License along
22 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
23 * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
24 */ 23 */
25 24
26#include "autoconf.h" 25#include "autoconf.h"
27 26
28#define PLUGIN_NAME "perl" 27#define PLUGIN_NAME "perl"
76# define newSVval64 newSVnv 75# define newSVval64 newSVnv
77# define SvVAL64 SvNV 76# define SvVAL64 SvNV
78#endif 77#endif
79 78
80static f_plug_api gethook = cfapi_get_hooks; 79static f_plug_api gethook = cfapi_get_hooks;
81static f_plug_api object_set_property = cfapi_object_set_property;
82static f_plug_api object_insert = cfapi_object_insert; 80static f_plug_api object_insert = cfapi_object_insert;
83 81
84static PerlInterpreter *perl; 82static PerlInterpreter *perl;
85 83
86double runtime; 84tstamp NOW, runtime;
87 85
88global gbl_ev; 86global gbl_ev;
89static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map; 87static AV *cb_global, *cb_attachable, *cb_object, *cb_player, *cb_client, *cb_type, *cb_map;
90static SV *sv_runtime, *sv_next_tick; 88static SV *sv_runtime, *sv_next_tick;
89
90bitset<NUM_EVENT_TYPES> ev_want_event;
91bitset<NUM_TYPES> ev_want_type;
91 92
92static HV 93static HV
93 *stash_cf, 94 *stash_cf,
94 *stash_cf_object_wrap, 95 *stash_cf_object_wrap,
95 *stash_cf_object_player_wrap, 96 *stash_cf_object_player_wrap,
167} 168}
168 169
169void 170void
170attachable::do_destroy () 171attachable::do_destroy ()
171{ 172{
172 invoke (EVENT_ATTACHABLE_DESTROY, DT_END); 173 INVOKE_ATTACHABLE (DESTROY, this);
173 174
174 if (cb) 175 if (cb)
175 { 176 {
176 SvREFCNT_dec (cb); 177 SvREFCNT_dec (cb);
177 cb = 0; 178 cb = 0;
654void 655void
655attachable::instantiate () 656attachable::instantiate ()
656{ 657{
657 if (attach) 658 if (attach)
658 { 659 {
659 invoke (EVENT_ATTACHABLE_INSTANTIATE, ARG_STRING (attach), DT_END); 660 INVOKE_ATTACHABLE (INSTANTIATE, this, ARG_STRING (attach));
660 attach = 0; 661 attach = 0;
661 } 662 }
662} 663}
663 664
664void 665void
665attachable::reattach () 666attachable::reattach ()
666{ 667{
667 optimise (); 668 optimise ();
668 //TODO: check for _attachment's, very important for restarts 669 //TODO: check for _attachment's, very important for restarts
669 invoke (EVENT_ATTACHABLE_REATTACH, DT_END); 670 INVOKE_ATTACHABLE (REATTACH, this);
670} 671}
671 672
672static event_klass klass_of[NUM_EVENT_TYPES] = { 673static event_klass klass_of[NUM_EVENT_TYPES] = {
673# define def(type,name) KLASS_ ## type, 674# define def(type,name) KLASS_ ## type,
674# include "eventinc.h" 675# include "eventinc.h"
717} 718}
718 719
719void 720void
720global::gather_callbacks (AV *&callbacks, event_type event) const 721global::gather_callbacks (AV *&callbacks, event_type event) const
721{ 722{
722 ::gather_callbacks (callbacks, cb_object, event); 723 ::gather_callbacks (callbacks, cb_global, event);
723} 724}
724 725
725void 726void
726object::gather_callbacks (AV *&callbacks, event_type event) const 727object::gather_callbacks (AV *&callbacks, event_type event) const
727{ 728{
728 if (subtype && type + subtype * NUM_SUBTYPES <= AvFILLp (cb_type)) 729 if (subtype && type + subtype * NUM_TYPES <= AvFILLp (cb_type))
729 { 730 {
730 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_SUBTYPES]; 731 SV *registry = AvARRAY (cb_type)[type + subtype * NUM_TYPES];
731 732
732 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV) 733 if (registry && SvROK (registry) && SvTYPE (SvRV (registry)) == SVt_PVAV)
733 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event); 734 ::gather_callbacks (callbacks, (AV *)SvRV (registry), event);
734 } 735 }
735 736
771{ 772{
772 attachable::gather_callbacks (callbacks, event); 773 attachable::gather_callbacks (callbacks, event);
773 ::gather_callbacks (callbacks, cb_map, event); 774 ::gather_callbacks (callbacks, cb_map, event);
774} 775}
775 776
777void
778_recalc_want (bitset<NUM_EVENT_TYPES> &set, AV *registry)
779{
780 for (int event = 0; event <= AvFILLp (registry); ++event)
781 {
782 SV *cbs_ = AvARRAY (registry)[event];
783
784 // element must be list of callback entries
785 if (cbs_ && SvROK (cbs_) && SvTYPE (SvRV (cbs_)) == SVt_PVAV)
786 {
787 AV *cbs = (AV *)SvRV (cbs_);
788
789 // no callback entries, no callbacks to call
790 if (AvFILLp (cbs) >= 0)
791 set.set (event);
792 }
793 }
794}
795
796// very slow and inefficient way to recalculate the global want bitsets
797void
798_recalc_want ()
799{
800 ev_want_event.reset ();
801
802 _recalc_want (ev_want_event, cb_global);
803 _recalc_want (ev_want_event, cb_attachable);
804 _recalc_want (ev_want_event, cb_object);
805 _recalc_want (ev_want_event, cb_client);
806 _recalc_want (ev_want_event, cb_player);
807 _recalc_want (ev_want_event, cb_map);
808
809 ev_want_type.reset ();
810
811 for (int type = 0; type <= AvFILLp (cb_type); ++type)
812 {
813 SV *cbs_ = AvARRAY (cb_type)[type];
814
815 // element must be list of callback entries
816 if (cbs_ && SvROK (cbs_) && SvTYPE (SvRV (cbs_)) == SVt_PVAV)
817 {
818 AV *cbs = (AV *)SvRV (cbs_);
819
820 // no callback entries, no callbacks to call
821 if (AvFILLp (cbs) >= 0)
822 ev_want_type.set (type % NUM_TYPES);
823 }
824 }
825}
826
776bool 827bool
777attachable::invoke (event_type event, ...) 828attachable::invoke (event_type event, ...)
778{ 829{
779 data_type dt; 830 data_type dt;
780 va_list ap;
781
782 va_start (ap, event);
783 831
784 // callback call ordering should be: 832 // callback call ordering should be:
785 // 1. per-object callback 833 // 1. per-object callback
786 // 2. per-class object 834 // 2. per-class object
787 // 3. per-type callback 835 // 3. per-type callback
791 gather_callbacks (callbacks, event); 839 gather_callbacks (callbacks, event);
792 840
793 // short-circuit processing if no callbacks found/defined 841 // short-circuit processing if no callbacks found/defined
794 if (!callbacks) 842 if (!callbacks)
795 return 0; 843 return 0;
844
845 va_list ap;
846 va_start (ap, event);
796 847
797 CALL_BEGIN (3); 848 CALL_BEGIN (3);
798 CALL_ARG_SV (newSViv (event)); // only used for debugging nowadays 849 CALL_ARG_SV (newSViv (event)); // only used for debugging nowadays
799 CALL_ARG_SV (newRV_noinc ((SV *)callbacks)); 850 CALL_ARG_SV (newRV_noinc ((SV *)callbacks));
800 851
877 CALL_ARG (make_core); 928 CALL_ARG (make_core);
878 CALL_CALL ("cf::post_cleanup", G_VOID); 929 CALL_CALL ("cf::post_cleanup", G_VOID);
879 CALL_END; 930 CALL_END;
880} 931}
881 932
933void
934cfperl_make_book (object *book, int level)
935{
936 CALL_BEGIN (2);
937 CALL_ARG (book);
938 CALL_ARG (level);
939 CALL_CALL ("ext::books::make_book", G_VOID);
940 CALL_END;
941}
942
882maptile * 943maptile *
883maptile::find_sync (const char *path, maptile *origin) 944maptile::find_sync (const char *path, maptile *origin)
884{ 945{
885 CALL_BEGIN (2); 946 CALL_BEGIN (2);
886 CALL_ARG (path); 947 CALL_ARG (path);
970 1031
971struct EventAPI *watcher_base::GEventAPI; 1032struct EventAPI *watcher_base::GEventAPI;
972struct CoroAPI *coroapi::GCoroAPI; 1033struct CoroAPI *coroapi::GCoroAPI;
973 1034
974int coroapi::cede_counter; 1035int coroapi::cede_counter;
975double (*coroapi::time)();
976double coroapi::next_cede; 1036tstamp coroapi::next_cede;
977 1037
978void coroapi::do_cede_to_tick () 1038void coroapi::do_cede_to_tick ()
979{ 1039{
980 cede_counter = 0; 1040 cede_counter = 0;
981 1041
1112 1172
1113 _connect_to_perl (); 1173 _connect_to_perl ();
1114 1174
1115 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1)); 1175 newCONSTSUB (stash_cf, "VERSION", newSVpv (VERSION, sizeof (VERSION) - 1));
1116 1176
1117 { 1177 //{
1118 require_pv ("Time::HiRes"); 1178 // require_pv ("Time::HiRes");
1119 1179 //
1120 SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0); 1180 // SV **svp = hv_fetch (PL_modglobal, "Time::NVtime", 12, 0);
1121 if (!svp) croak ("Time::HiRes is required"); 1181 // if (!svp) croak ("Time::HiRes is required");
1122 if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer"); 1182 // if (!SvIOK(*svp)) croak ("Time::NVtime isn’t a function pointer");
1123 coroapi::time = INT2PTR (double(*)(), SvIV(*svp)); 1183 // coroapi::time = INT2PTR (double(*)(), SvIV(*svp));
1124 } 1184 //}
1125 1185
1126 static const struct { 1186 static const struct {
1127 const char *name; 1187 const char *name;
1128 IV iv; 1188 IV iv;
1129 } *civ, const_iv[] = { 1189 } *civ, const_iv[] = {
1134 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1194 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1135 1195
1136 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1196 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1137 1197
1138 const_iv (MAX_TIME) 1198 const_iv (MAX_TIME)
1199
1200 const_iv (NUM_BODY_LOCATIONS)
1201 const_iv (body_range) const_iv (body_shield) const_iv (body_combat)
1202 const_iv (body_arm) const_iv (body_torso) const_iv (body_head)
1203 const_iv (body_neck) const_iv (body_skill) const_iv (body_finger)
1204 const_iv (body_shoulder) const_iv (body_foot) const_iv (body_hand)
1205 const_iv (body_wrist) const_iv (body_waist)
1139 1206
1140 const_iv (PLAYER) const_iv (TRANSPORT) const_iv (ROD) const_iv (TREASURE) 1207 const_iv (PLAYER) const_iv (TRANSPORT) const_iv (ROD) const_iv (TREASURE)
1141 const_iv (POTION) const_iv (FOOD) const_iv (POISON) const_iv (BOOK) 1208 const_iv (POTION) const_iv (FOOD) const_iv (POISON) const_iv (BOOK)
1142 const_iv (CLOCK) const_iv (ARROW) const_iv (BOW) const_iv (WEAPON) 1209 const_iv (CLOCK) const_iv (ARROW) const_iv (BOW) const_iv (WEAPON)
1143 const_iv (ARMOUR) const_iv (PEDESTAL) const_iv (ALTAR) const_iv (LOCKED_DOOR) 1210 const_iv (ARMOUR) const_iv (PEDESTAL) const_iv (ALTAR) const_iv (LOCKED_DOOR)
1164 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL) 1231 const_iv (CONTAINER) const_iv (ARMOUR_IMPROVER) const_iv (WEAPON_IMPROVER) const_iv (SKILLSCROLL)
1165 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE) 1232 const_iv (DEEP_SWAMP) const_iv (IDENTIFY_ALTAR) const_iv (MENU) const_iv (RUNE)
1166 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE) 1233 const_iv (TRAP) const_iv (POWER_CRYSTAL) const_iv (CORPSE) const_iv (DISEASE)
1167 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER) 1234 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1168 1235
1169 const_iv (NUM_SUBTYPES) 1236 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1170 1237
1171 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1238 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE)
1172 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM) 1239 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
1173 1240
1174 const_iv (AT_PHYSICAL) const_iv (AT_MAGIC) const_iv (AT_FIRE) const_iv (AT_ELECTRICITY) 1241 const_iv (AT_PHYSICAL) const_iv (AT_MAGIC) const_iv (AT_FIRE) const_iv (AT_ELECTRICITY)
1182 const_iv (WEAP_HIT) const_iv (WEAP_SLASH) const_iv (WEAP_PIERCE) const_iv (WEAP_CLEAVE) 1249 const_iv (WEAP_HIT) const_iv (WEAP_SLASH) const_iv (WEAP_PIERCE) const_iv (WEAP_CLEAVE)
1183 const_iv (WEAP_SLICE) const_iv (WEAP_STAB) const_iv (WEAP_WHIP) const_iv (WEAP_CRUSH) 1250 const_iv (WEAP_SLICE) const_iv (WEAP_STAB) const_iv (WEAP_WHIP) const_iv (WEAP_CRUSH)
1184 const_iv (WEAP_BLUD) 1251 const_iv (WEAP_BLUD)
1185 1252
1186 const_iv (FLAG_ALIVE) const_iv (FLAG_WIZ) const_iv (FLAG_REMOVED) const_iv (FLAG_FREED) 1253 const_iv (FLAG_ALIVE) const_iv (FLAG_WIZ) const_iv (FLAG_REMOVED) const_iv (FLAG_FREED)
1187 const_iv (FLAG_WAS_WIZ) const_iv (FLAG_APPLIED) const_iv (FLAG_UNPAID) const_iv (FLAG_USE_SHIELD) 1254 const_iv (FLAG_APPLIED) const_iv (FLAG_UNPAID) const_iv (FLAG_USE_SHIELD)
1188 const_iv (FLAG_NO_PICK) const_iv (FLAG_ANIMATE) const_iv (FLAG_MONSTER) const_iv (FLAG_FRIENDLY) 1255 const_iv (FLAG_NO_PICK) const_iv (FLAG_ANIMATE) const_iv (FLAG_MONSTER) const_iv (FLAG_FRIENDLY)
1189 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD) 1256 const_iv (FLAG_GENERATOR) const_iv (FLAG_IS_THROWN) const_iv (FLAG_AUTO_APPLY) const_iv (FLAG_PLAYER_SOLD)
1190 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE) 1257 const_iv (FLAG_SEE_INVISIBLE) const_iv (FLAG_CAN_ROLL) const_iv (FLAG_OVERLAY_FLOOR) const_iv (FLAG_IS_TURNABLE)
1191 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING) 1258 const_iv (FLAG_IS_USED_UP) const_iv (FLAG_IDENTIFIED) const_iv (FLAG_REFLECTING) const_iv (FLAG_CHANGING)
1192 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW) 1259 const_iv (FLAG_SPLITTING) const_iv (FLAG_HITBACK) const_iv (FLAG_STARTEQUIP) const_iv (FLAG_BLOCKSVIEW)
1219 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE) 1286 const_iv (UPD_LOCATION) const_iv (UPD_FLAGS) const_iv (UPD_WEIGHT) const_iv (UPD_FACE)
1220 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF) 1287 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1221 1288
1222 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1289 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE)
1223 1290
1291 const_iv (SP_RAISE_DEAD)
1292 const_iv (SP_RUNE)
1293 const_iv (SP_MAKE_MARK)
1294 const_iv (SP_BOLT)
1295 const_iv (SP_BULLET)
1296 const_iv (SP_EXPLOSION)
1297 const_iv (SP_CONE)
1298 const_iv (SP_BOMB)
1299 const_iv (SP_WONDER)
1300 const_iv (SP_SMITE)
1301 const_iv (SP_MAGIC_MISSILE)
1302 const_iv (SP_SUMMON_GOLEM)
1303 const_iv (SP_DIMENSION_DOOR)
1304 const_iv (SP_MAGIC_MAPPING)
1305 const_iv (SP_MAGIC_WALL)
1306 const_iv (SP_DESTRUCTION)
1307 const_iv (SP_PERCEIVE_SELF)
1308 const_iv (SP_WORD_OF_RECALL)
1309 const_iv (SP_INVISIBLE)
1310 const_iv (SP_PROBE)
1311 const_iv (SP_HEALING)
1312 const_iv (SP_CREATE_FOOD)
1313 const_iv (SP_EARTH_TO_DUST)
1314 const_iv (SP_CHANGE_ABILITY)
1315 const_iv (SP_BLESS)
1316 const_iv (SP_CURSE)
1317 const_iv (SP_SUMMON_MONSTER)
1318 const_iv (SP_CHARGING)
1319 const_iv (SP_POLYMORPH)
1320 const_iv (SP_ALCHEMY)
1321 const_iv (SP_REMOVE_CURSE)
1322 const_iv (SP_IDENTIFY)
1323 const_iv (SP_DETECTION)
1324 const_iv (SP_MOOD_CHANGE)
1325 const_iv (SP_MOVING_BALL)
1326 const_iv (SP_SWARM)
1327 const_iv (SP_CHANGE_MANA)
1328 const_iv (SP_DISPEL_RUNE)
1329 const_iv (SP_CREATE_MISSILE)
1330 const_iv (SP_CONSECRATE)
1331 const_iv (SP_ANIMATE_WEAPON)
1332 const_iv (SP_LIGHT)
1333 const_iv (SP_CHANGE_MAP_LIGHT)
1334 const_iv (SP_FAERY_FIRE)
1335 const_iv (SP_CAUSE_DISEASE)
1336 const_iv (SP_AURA)
1337 const_iv (SP_TOWN_PORTAL)
1338 const_iv (SP_PARTY_SPELL)
1339
1224 const_iv (F_APPLIED) const_iv (F_LOCATION) const_iv (F_UNPAID) const_iv (F_MAGIC) 1340 const_iv (F_APPLIED) const_iv (F_LOCATION) const_iv (F_UNPAID) const_iv (F_MAGIC)
1225 const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK) 1341 const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK)
1226 const_iv (F_LOCKED) 1342 const_iv (F_LOCKED)
1227 1343
1228 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) 1344 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL)
1330 } 1446 }
1331} 1447}
1332 1448
1333void _connect_to_perl () 1449void _connect_to_perl ()
1334 1450
1451void _recalc_want ()
1452
1335void _global_reattach () 1453void _global_reattach ()
1336 CODE: 1454 CODE:
1337{ 1455{
1338 // reattach to all attachable objects in the game. 1456 // reattach to all attachable objects in the game.
1339 for_all_clients (ns) 1457 for_all_clients (ns)
1403 default: croak ("cf::rndm requires none, one or two parameters."); break; 1521 default: croak ("cf::rndm requires none, one or two parameters."); break;
1404 } 1522 }
1405 OUTPUT: 1523 OUTPUT:
1406 RETVAL 1524 RETVAL
1407 1525
1526NV clamp (NV value, NV min_value, NV max_value)
1527 CODE:
1528 RETVAL = clamp (value, min_value, max_value);
1529 OUTPUT:
1530 RETVAL
1531
1532NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1533 CODE:
1534 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1535 OUTPUT:
1536 RETVAL
1537
1538void cede_to_tick ()
1539 CODE:
1540 coroapi::cede_to_tick ();
1541
1408void server_tick () 1542void server_tick ()
1409 CODE: 1543 CODE:
1544 NOW = now ();
1410 runtime = SvNVx (sv_runtime); 1545 runtime = SvNVx (sv_runtime);
1411 server_tick (); 1546 server_tick ();
1412 1547
1413void 1548void
1414log_backtrace (utf8_string msg) 1549log_backtrace (utf8_string msg)
1606object *actives (U32 index) 1741object *actives (U32 index)
1607 CODE: 1742 CODE:
1608 RETVAL = index < actives.size () ? actives [index] : 0; 1743 RETVAL = index < actives.size () ? actives [index] : 0;
1609 OUTPUT: RETVAL 1744 OUTPUT: RETVAL
1610 1745
1746const char *slot_use_name (U32 slot)
1747 ALIAS:
1748 slot_nonuse_name = 1
1749 CODE:
1750{
1751 if (slot >= NUM_BODY_LOCATIONS)
1752 croak ("body slot index out of range");
1753
1754 switch (ix)
1755 {
1756 case 0: RETVAL = body_locations[slot].use_name; break;
1757 case 1: RETVAL = body_locations[slot].nonuse_name; break;
1758 }
1759}
1760 OUTPUT:
1761 RETVAL
1762
1611# missing properties 1763# missing properties
1612 1764
1613object *head (object *op) 1765object *head (object *op)
1614 PROTOTYPE: $ 1766 PROTOTYPE: $
1615 CODE: 1767 CODE:
1616 RETVAL = op->head_ (); 1768 RETVAL = op->head_ ();
1617 OUTPUT: RETVAL
1618
1619int is_head (object *op)
1620 PROTOTYPE: $
1621 CODE:
1622 RETVAL = op->head_ () == op;
1623 OUTPUT: RETVAL 1769 OUTPUT: RETVAL
1624 1770
1625void 1771void
1626inv (object *obj) 1772inv (object *obj)
1627 PROTOTYPE: $ 1773 PROTOTYPE: $
1640int 1786int
1641num_animations (object *op) 1787num_animations (object *op)
1642 CODE: 1788 CODE:
1643 RETVAL = NUM_ANIMATIONS (op); 1789 RETVAL = NUM_ANIMATIONS (op);
1644 OUTPUT: RETVAL 1790 OUTPUT: RETVAL
1791
1792int slot_info (object *op, UV slot, int value = 0)
1793 ALIAS:
1794 slot_used = 1
1795 CODE:
1796{
1797 if (slot >= NUM_BODY_LOCATIONS)
1798 croak ("body slot index out of range");
1799
1800 RETVAL = ix ? op->slot[slot].used : op->slot[slot].info;
1801
1802 if (items > 2)
1803 if (ix)
1804 op->slot[slot].used = value;
1805 else
1806 op->slot[slot].info = value;
1807}
1808 OUTPUT:
1809 RETVAL
1645 1810
1646object *find_best_object_match (object *op, utf8_string match) 1811object *find_best_object_match (object *op, utf8_string match)
1647 1812
1648object *find_marked_object (object *op) 1813object *find_marked_object (object *op)
1649 1814
1765# dumb kludgy misdesigned plug-in api slowly gets on my nerves. 1930# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
1766 1931
1767object *new (utf8_string archetype = 0) 1932object *new (utf8_string archetype = 0)
1768 PROTOTYPE: ;$ 1933 PROTOTYPE: ;$
1769 CODE: 1934 CODE:
1770 RETVAL = archetype ? get_archetype (archetype) : cf_create_object (); 1935 RETVAL = archetype ? get_archetype (archetype) : object::create ();
1771 OUTPUT: 1936 OUTPUT:
1772 RETVAL 1937 RETVAL
1773 1938
1939# TODO: nuke
1774object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y) 1940object *insert_ob_in_map_at (object *ob, maptile *where, object_ornull *orig, int flag, int x, int y)
1775 PROTOTYPE: $$$$$$ 1941 PROTOTYPE: $$$$$$
1776 CODE: 1942 CODE:
1777{ 1943{
1778 int unused_type; 1944 int unused_type;
1831 1997
1832void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) 1998void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1833 CODE: 1999 CODE:
1834 new_draw_info (flags, 0, op, txt); 2000 new_draw_info (flags, 0, op, txt);
1835 2001
1836object *cf_player_send_inventory (object *op)
1837
1838octet_string cf_player_get_ip (object *op)
1839 ALIAS: ip = 0
1840
1841object *cf_player_get_marked_item (object *op)
1842 ALIAS: marked_item = 0
1843
1844void cf_player_set_marked_item (object *op, object *ob)
1845
1846partylist *cf_player_get_party (object *op)
1847 ALIAS: party = 0
1848
1849void cf_player_set_party (object *op, partylist *party)
1850
1851void kill_player (object *op) 2002void kill_player (object *op)
1852 2003
1853void esrv_update_item (object *op, int what, object *item) 2004void esrv_update_item (object *op, int what, object *item)
1854 C_ARGS: what, op, item 2005 C_ARGS: what, op, item
1855
1856void clear_los (object *op)
1857 2006
1858int command_summon (object *op, utf8_string params) 2007int command_summon (object *op, utf8_string params)
1859 2008
1860int command_arrest (object *op, utf8_string params) 2009int command_arrest (object *op, utf8_string params)
1861 2010
1879 CODE: 2028 CODE:
1880 pl->ob->stats.hp = pl->ob->stats.maxhp; 2029 pl->ob->stats.hp = pl->ob->stats.maxhp;
1881 pl->ob->stats.sp = pl->ob->stats.maxsp; 2030 pl->ob->stats.sp = pl->ob->stats.maxsp;
1882 pl->ob->stats.grace = pl->ob->stats.maxgrace; 2031 pl->ob->stats.grace = pl->ob->stats.maxgrace;
1883 pl->orig_stats = pl->ob->stats; 2032 pl->orig_stats = pl->ob->stats;
2033
2034void clear_los (player *pl)
1884 2035
1885void cf_player_move (player *pl, int dir) 2036void cf_player_move (player *pl, int dir)
1886 2037
1887void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0); 2038void play_sound_player_only (player *pl, int soundnum, int x = 0, int y = 0);
1888 2039
2240 rmp.decoroptions = decoroptions; 2391 rmp.decoroptions = decoroptions;
2241 rmp.orientation = orientation; 2392 rmp.orientation = orientation;
2242 rmp.origin_y = origin_y; 2393 rmp.origin_y = origin_y;
2243 rmp.origin_x = origin_x; 2394 rmp.origin_x = origin_x;
2244 rmp.random_seed = random_seed; 2395 rmp.random_seed = random_seed;
2245 rmp.total_map_hp = total_map_hp; 2396 rmp.total_map_hp = (uint64_t) total_map_hp;
2246 rmp.map_layout_style = map_layout_style; 2397 rmp.map_layout_style = map_layout_style;
2247 rmp.treasureoptions = treasureoptions; 2398 rmp.treasureoptions = treasureoptions;
2248 rmp.symmetry_used = symmetry_used; 2399 rmp.symmetry_used = symmetry_used;
2249 rmp.region = region; 2400 rmp.region = region;
2250 rmp.custom = custom; 2401 rmp.custom = custom;
2260 CODE: 2411 CODE:
2261 RETVAL = archetype::find (name); 2412 RETVAL = archetype::find (name);
2262 OUTPUT: 2413 OUTPUT:
2263 RETVAL 2414 RETVAL
2264 2415
2265archetype *first() 2416int archetypes_size ()
2266 PROTOTYPE: 2417 CODE:
2267 CODE:
2268 RETVAL = first_archetype; 2418 RETVAL = archetypes.size ();
2419 OUTPUT: RETVAL
2420
2421archetype *archetypes (U32 index)
2422 CODE:
2423 RETVAL = index < archetypes.size () ? archetypes [index] : 0;
2424 OUTPUT: RETVAL
2425
2426object *instantiate (archetype *arch)
2427 CODE:
2428 RETVAL = arch_to_object (arch);
2429 OUTPUT:
2269 OUTPUT: RETVAL 2430 RETVAL
2270 2431
2271INCLUDE: $PERL $srcdir/genacc archetype ../include/object.h | 2432INCLUDE: $PERL $srcdir/genacc archetype ../include/object.h |
2272 2433
2273MODULE = cf PACKAGE = cf::party 2434MODULE = cf PACKAGE = cf::party
2274 2435

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines