ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/plugins/cfperl/cfperl.xs
(Generate patch)

Comparing deliantra/server/plugins/cfperl/cfperl.xs (file contents):
Revision 1.22 by root, Fri Feb 10 07:37:13 2006 UTC vs.
Revision 1.27 by root, Sun Mar 5 18:48:50 2006 UTC

29#include <XSUB.h> 29#include <XSUB.h>
30 30
31#undef save_long // clashes with libproto.h 31#undef save_long // clashes with libproto.h
32 32
33#define PLUGIN_NAME "perl" 33#define PLUGIN_NAME "perl"
34#define PLUGIN_VERSION "cfperl 0.1" 34#define PLUGIN_VERSION "cfperl 0.2"
35 35
36#ifndef __CEXTRACT__ 36#ifndef __CEXTRACT__
37#include <plugin.h> 37#include <plugin.h>
38#endif 38#endif
39 39
64{ 64{
65 object* who; 65 object* who;
66 object* activator; 66 object* activator;
67 object* third; 67 object* third;
68 char message[1024]; 68 char message[1024];
69 int fix; 69 int fix; // seems to be python-only, and should not be part of the API
70 int event_code; 70 int event_code;
71 char extension[1024]; // name field, should invoke specific perl extension 71 char extension[1024]; // name field, should invoke specific perl extension
72 char options[1024]; // slaying field of event_connectors 72 char options[1024]; // slaying field of event_connectors
73 int returnvalue; 73 int returnvalue;
74} CFPContext; 74} CFPContext;
75
76//static int current_command = -999;
77 75
78static HV *obj_cache; 76static HV *obj_cache;
79static PerlInterpreter *perl; 77static PerlInterpreter *perl;
80 78
81////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 79//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
192 va_list args; 190 va_list args;
193 va_start (args, type); 191 va_start (args, type);
194 192
195 switch (type) 193 switch (type)
196 { 194 {
195#if 0
196 case CFAPI_INT16:
197 sv = newSViv (*va_arg (args, sint16_t *));
198 break;
199#endif
200
197 case CFAPI_INT: 201 case CFAPI_INT:
198 sv = newSViv (*va_arg (args, int *)); 202 sv = newSViv (*va_arg (args, int *));
199 break; 203 break;
200 204
201 case CFAPI_LONG: 205 case CFAPI_LONG:
749 const_iv (ST_BD_BUILD) 753 const_iv (ST_BD_BUILD)
750 const_iv (ST_BD_REMOVE) 754 const_iv (ST_BD_REMOVE)
751 const_iv (ST_MAT_FLOOR) 755 const_iv (ST_MAT_FLOOR)
752 const_iv (ST_MAT_WALL) 756 const_iv (ST_MAT_WALL)
753 const_iv (ST_MAT_ITEM) 757 const_iv (ST_MAT_ITEM)
758
759 const_iv (AT_PHYSICAL)
760 const_iv (AT_MAGIC)
761 const_iv (AT_FIRE)
762 const_iv (AT_ELECTRICITY)
763 const_iv (AT_COLD)
764 const_iv (AT_CONFUSION)
765 const_iv (AT_ACID)
766 const_iv (AT_DRAIN)
767 const_iv (AT_WEAPONMAGIC)
768 const_iv (AT_GHOSTHIT)
769 const_iv (AT_POISON)
770 const_iv (AT_SLOW)
771 const_iv (AT_PARALYZE)
772 const_iv (AT_TURN_UNDEAD)
773 const_iv (AT_FEAR)
774 const_iv (AT_CANCELLATION)
775 const_iv (AT_DEPLETE)
776 const_iv (AT_DEATH)
777 const_iv (AT_CHAOS)
778 const_iv (AT_COUNTERSPELL)
779 const_iv (AT_GODPOWER)
780 const_iv (AT_HOLYWORD)
781 const_iv (AT_BLIND)
782 const_iv (AT_INTERNAL)
783 const_iv (AT_LIFE_STEALING)
784 const_iv (AT_DISEASE)
754 785
755 const_iv (QUEST_IN_PROGRESS) 786 const_iv (QUEST_IN_PROGRESS)
756 const_iv (QUEST_DONE_QUEST) 787 const_iv (QUEST_DONE_QUEST)
757 const_iv (QUEST_DONE_TASK) 788 const_iv (QUEST_DONE_TASK)
758 const_iv (QUEST_START_QUEST) 789 const_iv (QUEST_START_QUEST)
1170 int unused_type; 1201 int unused_type;
1171 object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); 1202 object_set_property (&unused_type, obj, idx, (double)SvNV (newval));
1172 } 1203 }
1173 break; 1204 break;
1174 case CFAPI_STRING: 1205 case CFAPI_STRING:
1175 cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); 1206 cf_object_set_string_property (obj, idx, SvOK (newval) ? SvPV_nolen (newval) : 0);
1207 break;
1208 case CFAPI_POBJECT:
1209 {
1210 int unused_type;
1211 object_set_property (&unused_type, obj, idx, (object *)SvPTR_ornull (newval, "cf::object"));
1212 }
1176 break; 1213 break;
1177 default: 1214 default:
1178 croak ("unhandled type '%d' in set_property '%d'", type, idx); 1215 croak ("unhandled type '%d' in set_property '%d'", type, idx);
1179 } 1216 }
1180 1217
1218# missing properties
1219
1220void
1221set_attacktype (object *obj, U32 attacktype)
1222 CODE:
1223 obj->attacktype = attacktype;
1224
1225U32
1226get_attacktype (object *obj)
1227 ALIAS:
1228 attacktype = 0
1229 CODE:
1230 RETVAL = obj->attacktype;
1231 OUTPUT: RETVAL
1232
1233void
1234set_food (object *obj, int food)
1235 CODE:
1236 obj->stats.food = food;
1237
1238int
1239get_food (object *obj)
1240 ALIAS:
1241 food = 0
1242 CODE:
1243 RETVAL = obj->stats.food;
1244 OUTPUT: RETVAL
1245
1181void 1246void
1182inv (object *obj) 1247inv (object *obj)
1183 PROTOTYPE: $ 1248 PROTOTYPE: $
1184 PPCODE: 1249 PPCODE:
1185{ 1250{
1216 1281
1217int cf_object_pay_item (object *op, object *buyer) 1282int cf_object_pay_item (object *op, object *buyer)
1218 1283
1219int cf_object_pay_amount (object *op, double amount) 1284int cf_object_pay_amount (object *op, double amount)
1220 1285
1221int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *sp_, char *flags) 1286int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *spell_ob, char *stringarg = 0)
1222 1287
1223int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *flags) 1288int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *stringarg = 0)
1224 1289
1225void cf_object_learn_spell (object *op, object *sp) 1290void cf_object_learn_spell (object *op, object *sp)
1226 1291
1227void cf_object_forget_spell (object *op, object *sp) 1292void cf_object_forget_spell (object *op, object *sp)
1228 1293
1264char *cf_object_get_key (object *op, char *keyname) 1329char *cf_object_get_key (object *op, char *keyname)
1265 ALIAS: key = 0 1330 ALIAS: key = 0
1266 1331
1267void cf_object_set_key (object *op, char *keyname, char *value) 1332void cf_object_set_key (object *op, char *keyname, char *value)
1268 1333
1334object *cf_create_object_by_name (const char *name)
1335
1269MODULE = cf PACKAGE = cf::object PREFIX = cf_ 1336MODULE = cf PACKAGE = cf::object PREFIX = cf_
1270 1337
1271void cf_fix_object (object *pl) 1338void cf_fix_object (object *pl)
1272 ALIAS: fix = 0 1339 ALIAS: fix = 0
1273 1340
1274object *cf_insert_ob_in_ob (object *ob, object *where) 1341object *cf_insert_ob_in_ob (object *ob, object *where)
1275 1342
1276object *create_object_by_name (const char *name = 0) 1343# no clean way to get an object from an archetype - stupid idiotic
1344# dumb kludgy misdesigned plug-in api slowly gets on my nerves.
1345
1346object *new (const char *archetype = 0)
1277 PROTOTYPE: ;$ 1347 PROTOTYPE: ;$
1278 ALIAS:
1279 create_object = 0
1280 new = 0
1281 CODE: 1348 CODE:
1282 RETVAL = name ? cf_create_object_by_name (name) : cf_create_object (); 1349 RETVAL = archetype ? get_archetype (archetype) : cf_create_object ();
1283 OUTPUT: 1350 OUTPUT:
1284 RETVAL 1351 RETVAL
1285 1352
1286object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y) 1353object *insert_ob_in_map_at (object *ob, mapstruct *where, object_ornull *orig, int flag, int x, int y)
1287 PROTOTYPE: $$$$$$ 1354 PROTOTYPE: $$$$$$

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines