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.213 by root, Thu May 24 03:33:29 2007 UTC

1/*****************************************************************************/
2/* CrossFire, A Multiplayer game for the X Window System */
3/*****************************************************************************/
4
5/* 1/*
2 * CrossFire, A Multiplayer game
3 *
6 * This code is placed under the GNU General Public Licence (GPL) 4 * This code is placed under the GNU General Public Licence (GPL)
7 * 5 *
8 * Copyright (C) 2001-2005 by Chachkoff Yann 6 * Copyright (C) 2001-2005 by Chachkoff Yann
9 * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de> 7 * Copyright (C) 2006,2007 by Marc Lehmann <cf@schmorp.de>
10 * 8 *
86double runtime; 84double 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,
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::vinvoke (event_type event, va_list &ap)
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
874cfperl_cleanup (int make_core) 922cfperl_cleanup (int make_core)
875{ 923{
876 CALL_BEGIN (1); 924 CALL_BEGIN (1);
877 CALL_ARG (make_core); 925 CALL_ARG (make_core);
878 CALL_CALL ("cf::post_cleanup", G_VOID); 926 CALL_CALL ("cf::post_cleanup", G_VOID);
927 CALL_END;
928}
929
930void
931cfperl_make_book (object *book, int level)
932{
933 CALL_BEGIN (2);
934 CALL_ARG (book);
935 CALL_ARG (level);
936 CALL_CALL ("ext::books::make_book", G_VOID);
879 CALL_END; 937 CALL_END;
880} 938}
881 939
882maptile * 940maptile *
883maptile::find_sync (const char *path, maptile *origin) 941maptile::find_sync (const char *path, maptile *origin)
1134 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd) 1192 const_iv (Map0Cmd) const_iv (Map1Cmd) const_iv (Map1aCmd)
1135 1193
1136 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y) 1194 const_iv (MAP_CLIENT_X) const_iv (MAP_CLIENT_Y)
1137 1195
1138 const_iv (MAX_TIME) 1196 const_iv (MAX_TIME)
1197
1198 const_iv (NUM_BODY_LOCATIONS)
1199 const_iv (body_range) const_iv (body_shield) const_iv (body_combat)
1200 const_iv (body_arm) const_iv (body_torso) const_iv (body_head)
1201 const_iv (body_neck) const_iv (body_skill) const_iv (body_finger)
1202 const_iv (body_shoulder) const_iv (body_foot) const_iv (body_hand)
1203 const_iv (body_wrist) const_iv (body_waist)
1139 1204
1140 const_iv (PLAYER) const_iv (TRANSPORT) const_iv (ROD) const_iv (TREASURE) 1205 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) 1206 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) 1207 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) 1208 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) 1229 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) 1230 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) 1231 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) 1232 const_iv (SYMPTOM) const_iv (BUILDER) const_iv (MATERIAL) const_iv (ITEM_TRANSFORMER)
1168 1233
1169 const_iv (NUM_SUBTYPES) 1234 const_iv (NUM_TYPES) const_iv (NUM_SUBTYPES)
1170 1235
1171 const_iv (ST_BD_BUILD) const_iv (ST_BD_REMOVE) 1236 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) 1237 const_iv (ST_MAT_FLOOR) const_iv (ST_MAT_WALL) const_iv (ST_MAT_ITEM)
1173 1238
1174 const_iv (AT_PHYSICAL) const_iv (AT_MAGIC) const_iv (AT_FIRE) const_iv (AT_ELECTRICITY) 1239 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) 1247 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) 1248 const_iv (WEAP_SLICE) const_iv (WEAP_STAB) const_iv (WEAP_WHIP) const_iv (WEAP_CRUSH)
1184 const_iv (WEAP_BLUD) 1249 const_iv (WEAP_BLUD)
1185 1250
1186 const_iv (FLAG_ALIVE) const_iv (FLAG_WIZ) const_iv (FLAG_REMOVED) const_iv (FLAG_FREED) 1251 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) 1252 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) 1253 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) 1254 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) 1255 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) 1256 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) 1257 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) 1284 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) 1285 const_iv (UPD_NAME) const_iv (UPD_ANIM) const_iv (UPD_ANIMSPEED) const_iv (UPD_NROF)
1221 1286
1222 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE) 1287 const_iv (UPD_SP_MANA) const_iv (UPD_SP_GRACE) const_iv (UPD_SP_DAMAGE)
1223 1288
1289 const_iv (SP_RAISE_DEAD)
1290 const_iv (SP_RUNE)
1291 const_iv (SP_MAKE_MARK)
1292 const_iv (SP_BOLT)
1293 const_iv (SP_BULLET)
1294 const_iv (SP_EXPLOSION)
1295 const_iv (SP_CONE)
1296 const_iv (SP_BOMB)
1297 const_iv (SP_WONDER)
1298 const_iv (SP_SMITE)
1299 const_iv (SP_MAGIC_MISSILE)
1300 const_iv (SP_SUMMON_GOLEM)
1301 const_iv (SP_DIMENSION_DOOR)
1302 const_iv (SP_MAGIC_MAPPING)
1303 const_iv (SP_MAGIC_WALL)
1304 const_iv (SP_DESTRUCTION)
1305 const_iv (SP_PERCEIVE_SELF)
1306 const_iv (SP_WORD_OF_RECALL)
1307 const_iv (SP_INVISIBLE)
1308 const_iv (SP_PROBE)
1309 const_iv (SP_HEALING)
1310 const_iv (SP_CREATE_FOOD)
1311 const_iv (SP_EARTH_TO_DUST)
1312 const_iv (SP_CHANGE_ABILITY)
1313 const_iv (SP_BLESS)
1314 const_iv (SP_CURSE)
1315 const_iv (SP_SUMMON_MONSTER)
1316 const_iv (SP_CHARGING)
1317 const_iv (SP_POLYMORPH)
1318 const_iv (SP_ALCHEMY)
1319 const_iv (SP_REMOVE_CURSE)
1320 const_iv (SP_IDENTIFY)
1321 const_iv (SP_DETECTION)
1322 const_iv (SP_MOOD_CHANGE)
1323 const_iv (SP_MOVING_BALL)
1324 const_iv (SP_SWARM)
1325 const_iv (SP_CHANGE_MANA)
1326 const_iv (SP_DISPEL_RUNE)
1327 const_iv (SP_CREATE_MISSILE)
1328 const_iv (SP_CONSECRATE)
1329 const_iv (SP_ANIMATE_WEAPON)
1330 const_iv (SP_LIGHT)
1331 const_iv (SP_CHANGE_MAP_LIGHT)
1332 const_iv (SP_FAERY_FIRE)
1333 const_iv (SP_CAUSE_DISEASE)
1334 const_iv (SP_AURA)
1335 const_iv (SP_TOWN_PORTAL)
1336 const_iv (SP_PARTY_SPELL)
1337
1224 const_iv (F_APPLIED) const_iv (F_LOCATION) const_iv (F_UNPAID) const_iv (F_MAGIC) 1338 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) 1339 const_iv (F_CURSED) const_iv (F_DAMNED) const_iv (F_OPEN) const_iv (F_NOPICK)
1226 const_iv (F_LOCKED) 1340 const_iv (F_LOCKED)
1227 1341
1228 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL) 1342 const_iv (F_BUY) const_iv (F_SHOP) const_iv (F_SELL)
1330 } 1444 }
1331} 1445}
1332 1446
1333void _connect_to_perl () 1447void _connect_to_perl ()
1334 1448
1449void _recalc_want ()
1450
1335void _global_reattach () 1451void _global_reattach ()
1336 CODE: 1452 CODE:
1337{ 1453{
1338 // reattach to all attachable objects in the game. 1454 // reattach to all attachable objects in the game.
1339 for_all_clients (ns) 1455 for_all_clients (ns)
1402 case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break; 1518 case 2: RETVAL = rndm (SvIV (ST (0)), SvIV (ST (1))); break;
1403 default: croak ("cf::rndm requires none, one or two parameters."); break; 1519 default: croak ("cf::rndm requires none, one or two parameters."); break;
1404 } 1520 }
1405 OUTPUT: 1521 OUTPUT:
1406 RETVAL 1522 RETVAL
1523
1524NV clamp (NV value, NV min_value, NV max_value)
1525 CODE:
1526 RETVAL = clamp (value, min_value, max_value);
1527 OUTPUT:
1528 RETVAL
1529
1530NV lerp (NV value, NV min_in, NV max_in, NV min_out, NV max_out)
1531 CODE:
1532 RETVAL = lerp (value, min_in, max_in, min_out, max_out);
1533 OUTPUT:
1534 RETVAL
1535
1536void cede_to_tick ()
1537 CODE:
1538 coroapi::cede_to_tick ();
1407 1539
1408void server_tick () 1540void server_tick ()
1409 CODE: 1541 CODE:
1410 runtime = SvNVx (sv_runtime); 1542 runtime = SvNVx (sv_runtime);
1411 server_tick (); 1543 server_tick ();
1606object *actives (U32 index) 1738object *actives (U32 index)
1607 CODE: 1739 CODE:
1608 RETVAL = index < actives.size () ? actives [index] : 0; 1740 RETVAL = index < actives.size () ? actives [index] : 0;
1609 OUTPUT: RETVAL 1741 OUTPUT: RETVAL
1610 1742
1743const char *slot_save_name (U32 slot)
1744 ALIAS:
1745 slot_use_name = 1
1746 slot_nonuse_name = 2
1747 CODE:
1748{
1749 if (slot >= NUM_BODY_LOCATIONS)
1750 croak ("body slot index out of range");
1751
1752 switch (ix)
1753 {
1754 case 0: RETVAL = body_locations[slot].save_name; break;
1755 case 1: RETVAL = body_locations[slot].use_name; break;
1756 case 2: RETVAL = body_locations[slot].nonuse_name; break;
1757 }
1758}
1759 OUTPUT:
1760 RETVAL
1761
1611# missing properties 1762# missing properties
1612 1763
1613object *head (object *op) 1764object *head (object *op)
1614 PROTOTYPE: $ 1765 PROTOTYPE: $
1615 CODE: 1766 CODE:
1640int 1791int
1641num_animations (object *op) 1792num_animations (object *op)
1642 CODE: 1793 CODE:
1643 RETVAL = NUM_ANIMATIONS (op); 1794 RETVAL = NUM_ANIMATIONS (op);
1644 OUTPUT: RETVAL 1795 OUTPUT: RETVAL
1796
1797int slot_info (object *op, UV slot, int value = 0)
1798 ALIAS:
1799 slot_used = 1
1800 CODE:
1801{
1802 if (slot >= NUM_BODY_LOCATIONS)
1803 croak ("body slot index out of range");
1804
1805 RETVAL = ix ? op->slot[slot].used : op->slot[slot].info;
1806
1807 if (items > 2)
1808 if (ix)
1809 op->slot[slot].used = value;
1810 else
1811 op->slot[slot].info = value;
1812}
1813 OUTPUT:
1814 RETVAL
1645 1815
1646object *find_best_object_match (object *op, utf8_string match) 1816object *find_best_object_match (object *op, utf8_string match)
1647 1817
1648object *find_marked_object (object *op) 1818object *find_marked_object (object *op)
1649 1819
1830void check_score (object *op) 2000void check_score (object *op)
1831 2001
1832void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE) 2002void message (object *op, utf8_string txt, int flags = NDI_ORANGE | NDI_UNIQUE)
1833 CODE: 2003 CODE:
1834 new_draw_info (flags, 0, op, txt); 2004 new_draw_info (flags, 0, op, txt);
1835
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 2005
1851void kill_player (object *op) 2006void kill_player (object *op)
1852 2007
1853void esrv_update_item (object *op, int what, object *item) 2008void esrv_update_item (object *op, int what, object *item)
1854 C_ARGS: what, op, item 2009 C_ARGS: what, op, item
2266 PROTOTYPE: 2421 PROTOTYPE:
2267 CODE: 2422 CODE:
2268 RETVAL = first_archetype; 2423 RETVAL = first_archetype;
2269 OUTPUT: RETVAL 2424 OUTPUT: RETVAL
2270 2425
2426object *instantiate (archetype *arch)
2427 CODE:
2428 RETVAL = arch_to_object (arch);
2429 OUTPUT:
2430 RETVAL
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
2275partylist *first () 2436partylist *first ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines