1 |
root |
1.1 |
/*****************************************************************************/ |
2 |
root |
1.7 |
/* CrossFire, A Multiplayer game for the X Window System */ |
3 |
root |
1.1 |
/* */ |
4 |
|
|
/*****************************************************************************/ |
5 |
|
|
|
6 |
root |
1.7 |
/* |
7 |
|
|
* This code is placed under the GNU General Public Licence (GPL) |
8 |
|
|
* |
9 |
|
|
* Copyright (C) 2001-2005 by Chachkoff Yann |
10 |
|
|
* Copyright (C) 2006 by Marc Lehmann <cf@schmorpd.e> |
11 |
|
|
* |
12 |
|
|
* This program is free software; you can redistribute it and/or modify |
13 |
|
|
* it under the terms of the GNU General Public License as published by |
14 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
15 |
|
|
* (at your option) any later version. |
16 |
|
|
* |
17 |
|
|
* This program is distributed in the hope that it will be useful, |
18 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 |
|
|
* GNU General Public License for more details. |
21 |
|
|
* |
22 |
|
|
* You should have received a copy of the GNU General Public License |
23 |
|
|
* along with this program; if not, write to the Free Software |
24 |
|
|
* Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
25 |
|
|
*/ |
26 |
|
|
|
27 |
root |
1.1 |
#include <EXTERN.h> |
28 |
|
|
#include <perl.h> |
29 |
|
|
#include <XSUB.h> |
30 |
|
|
|
31 |
|
|
#undef save_long // clashes with libproto.h |
32 |
|
|
|
33 |
root |
1.15 |
#define PLUGIN_NAME "perl" |
34 |
root |
1.1 |
#define PLUGIN_VERSION "cfperl 0.0" |
35 |
|
|
|
36 |
|
|
#ifndef __CEXTRACT__ |
37 |
|
|
#include <plugin.h> |
38 |
|
|
#endif |
39 |
|
|
|
40 |
|
|
#undef MODULEAPI |
41 |
|
|
#ifdef WIN32 |
42 |
|
|
#else |
43 |
|
|
#define MODULEAPI |
44 |
|
|
#endif |
45 |
|
|
|
46 |
|
|
#include <plugin_common.h> |
47 |
|
|
|
48 |
|
|
#include <stdarg.h> |
49 |
|
|
|
50 |
|
|
#include "perlxsi.c" |
51 |
|
|
|
52 |
|
|
static f_plug_api gethook; |
53 |
|
|
static f_plug_api registerGlobalEvent; |
54 |
|
|
static f_plug_api unregisterGlobalEvent; |
55 |
|
|
static f_plug_api systemDirectory; |
56 |
root |
1.10 |
static f_plug_api object_set_property; |
57 |
root |
1.11 |
static f_plug_api map_get_map; |
58 |
root |
1.1 |
|
59 |
|
|
typedef struct |
60 |
|
|
{ |
61 |
|
|
object* who; |
62 |
|
|
object* activator; |
63 |
|
|
object* third; |
64 |
|
|
char message[1024]; |
65 |
|
|
int fix; |
66 |
|
|
int event_code; |
67 |
root |
1.15 |
char extension[1024]; // name field, should invoke specific perl extension |
68 |
|
|
char options[1024]; // slaying field of event_connectors |
69 |
root |
1.1 |
int returnvalue; |
70 |
|
|
} CFPContext; |
71 |
|
|
|
72 |
|
|
//static int current_command = -999; |
73 |
|
|
|
74 |
root |
1.14 |
static HV *obj_cache; |
75 |
root |
1.1 |
static PerlInterpreter *perl; |
76 |
|
|
|
77 |
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
78 |
|
|
|
79 |
root |
1.14 |
// garbage collect some perl objects, if possible |
80 |
|
|
// all objects no longer referenced and empty are |
81 |
|
|
// eligible for destruction. |
82 |
|
|
void |
83 |
|
|
clean_obj_cache () |
84 |
|
|
{ |
85 |
|
|
int todo = 10; |
86 |
|
|
do |
87 |
|
|
{ |
88 |
|
|
I32 klen; |
89 |
|
|
char *key; |
90 |
|
|
HE *he = hv_iternext (obj_cache); |
91 |
|
|
|
92 |
|
|
if (he) |
93 |
|
|
{ |
94 |
|
|
SV *sv = SvRV (hv_iterval (obj_cache, he)); |
95 |
|
|
|
96 |
|
|
// emopty and unreferened? nuke it |
97 |
|
|
if (SvREFCNT (sv) == 1 && !HvFILL ((HV *)sv)) |
98 |
|
|
{ |
99 |
|
|
hv_delete (obj_cache, HeKEY (he), HeKLEN (he), G_DISCARD); |
100 |
|
|
todo++; |
101 |
|
|
} |
102 |
|
|
} |
103 |
|
|
else |
104 |
|
|
break; |
105 |
|
|
} |
106 |
|
|
while (--todo); |
107 |
|
|
} |
108 |
|
|
|
109 |
root |
1.1 |
static SV * |
110 |
|
|
newSVptr (void *ptr, const char *klass) |
111 |
|
|
{ |
112 |
|
|
if (!ptr) |
113 |
|
|
return &PL_sv_undef; |
114 |
|
|
|
115 |
|
|
HV *hv = newHV (); |
116 |
|
|
sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
117 |
|
|
return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
118 |
|
|
} |
119 |
|
|
|
120 |
root |
1.14 |
static SV * |
121 |
|
|
newSVptr_cached (void *ptr, const char *klass) |
122 |
|
|
{ |
123 |
|
|
SV *sv, **he; |
124 |
|
|
|
125 |
|
|
if (!ptr) |
126 |
|
|
return &PL_sv_undef; |
127 |
|
|
|
128 |
|
|
he = hv_fetch (obj_cache, (char *)&ptr, sizeof (ptr), 0); |
129 |
|
|
|
130 |
|
|
if (he) |
131 |
|
|
sv = *he; |
132 |
|
|
else |
133 |
|
|
{ |
134 |
|
|
sv = newSVptr (ptr, klass); |
135 |
|
|
hv_store (obj_cache, (char *)&ptr, sizeof (ptr), sv, 0); |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
return newSVsv (sv); |
139 |
|
|
} |
140 |
|
|
|
141 |
root |
1.1 |
static void |
142 |
|
|
clearSVptr (SV *sv) |
143 |
|
|
{ |
144 |
|
|
if (SvROK (sv)) |
145 |
|
|
sv = SvRV (sv); |
146 |
|
|
|
147 |
|
|
hv_clear ((HV *)sv); |
148 |
|
|
sv_unmagic (sv, PERL_MAGIC_ext); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
static long |
152 |
|
|
SvPTR (SV *sv, const char *klass) |
153 |
|
|
{ |
154 |
|
|
if (!sv_derived_from (sv, klass)) |
155 |
|
|
croak ("object of type %s expected", klass); |
156 |
|
|
|
157 |
|
|
MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
158 |
|
|
|
159 |
|
|
if (!mg) |
160 |
|
|
croak ("perl code used %s object, but C object is already destroyed, caught", klass); |
161 |
|
|
|
162 |
|
|
return (long)mg->mg_ptr; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
SV * |
166 |
|
|
newSVcfapi (int type, ...) |
167 |
|
|
{ |
168 |
|
|
SV *sv; |
169 |
|
|
|
170 |
|
|
va_list args; |
171 |
|
|
va_start (args, type); |
172 |
|
|
|
173 |
|
|
switch (type) |
174 |
|
|
{ |
175 |
|
|
case CFAPI_INT: |
176 |
|
|
sv = newSViv (*va_arg (args, int *)); |
177 |
|
|
break; |
178 |
|
|
|
179 |
|
|
case CFAPI_LONG: |
180 |
|
|
sv = newSViv (*va_arg (args, long *)); |
181 |
|
|
break; |
182 |
|
|
|
183 |
|
|
case CFAPI_DOUBLE: |
184 |
|
|
sv = newSViv (*va_arg (args, double *)); |
185 |
|
|
break; |
186 |
|
|
|
187 |
|
|
case CFAPI_STRING: |
188 |
root |
1.7 |
{ |
189 |
|
|
char *str = va_arg (args, char *); |
190 |
|
|
sv = str ? newSVpv (str, 0) : &PL_sv_undef; |
191 |
|
|
} |
192 |
root |
1.1 |
break; |
193 |
|
|
|
194 |
|
|
case CFAPI_POBJECT: |
195 |
|
|
{ |
196 |
|
|
object *obj = va_arg (args, object *); |
197 |
|
|
|
198 |
|
|
if (!obj) |
199 |
|
|
sv = &PL_sv_undef; |
200 |
|
|
else |
201 |
|
|
switch (*(int *)cf_object_get_property (obj, CFAPI_OBJECT_PROP_TYPE)) |
202 |
|
|
{ |
203 |
|
|
case MAP: |
204 |
root |
1.14 |
sv = newSVptr_cached (obj, "cf::object::map"); |
205 |
root |
1.1 |
break; |
206 |
|
|
|
207 |
|
|
case PLAYER: |
208 |
root |
1.14 |
sv = newSVptr_cached (obj, "cf::object::player"); |
209 |
root |
1.1 |
break; |
210 |
|
|
|
211 |
|
|
default: |
212 |
root |
1.14 |
sv = newSVptr_cached (obj, "cf::object"); |
213 |
root |
1.1 |
break; |
214 |
|
|
} |
215 |
|
|
} |
216 |
|
|
break; |
217 |
|
|
|
218 |
|
|
case CFAPI_PMAP: |
219 |
root |
1.6 |
sv = newSVptr (va_arg (args, mapstruct *), "cf::map"); |
220 |
root |
1.1 |
break; |
221 |
|
|
|
222 |
|
|
case CFAPI_PPLAYER: |
223 |
root |
1.6 |
sv = newSVptr (va_arg (args, player *), "cf::player"); |
224 |
root |
1.1 |
break; |
225 |
|
|
|
226 |
|
|
case CFAPI_PARCH: |
227 |
root |
1.6 |
sv = newSVptr (va_arg (args, archetype *), "cf::arch"); |
228 |
root |
1.1 |
break; |
229 |
|
|
|
230 |
|
|
case CFAPI_PPARTY: |
231 |
root |
1.6 |
sv = newSVptr (va_arg (args, partylist *), "cf::party"); |
232 |
root |
1.1 |
break; |
233 |
|
|
|
234 |
|
|
case CFAPI_PREGION: |
235 |
root |
1.6 |
sv = newSVptr (va_arg (args, region *), "cf::region"); |
236 |
root |
1.1 |
break; |
237 |
|
|
|
238 |
|
|
default: |
239 |
|
|
assert (("unhandled type in newSVcfapi", 0)); |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
va_end (args); |
243 |
|
|
|
244 |
|
|
return sv; |
245 |
|
|
} |
246 |
|
|
|
247 |
|
|
///////////////////////////////////////////////////////////////////////////// |
248 |
|
|
|
249 |
|
|
void |
250 |
root |
1.15 |
inject_event (const char *func, CFPContext *context) |
251 |
root |
1.1 |
{ |
252 |
|
|
dSP; |
253 |
|
|
|
254 |
|
|
ENTER; |
255 |
|
|
SAVETMPS; |
256 |
|
|
|
257 |
|
|
PUSHMARK (SP); |
258 |
|
|
|
259 |
|
|
HV *hv = newHV (); |
260 |
|
|
#define hv_context(type,addr,expr) hv_store (hv, #expr, sizeof (#expr) - 1, newSVcfapi (type, addr context->expr), 0) |
261 |
|
|
hv_context (CFAPI_POBJECT, ,who); |
262 |
|
|
hv_context (CFAPI_POBJECT, ,activator); |
263 |
|
|
hv_context (CFAPI_POBJECT, ,third); |
264 |
|
|
hv_context (CFAPI_STRING , ,message); |
265 |
|
|
hv_context (CFAPI_INT ,&,fix); |
266 |
|
|
hv_context (CFAPI_INT ,&,event_code); |
267 |
|
|
hv_context (CFAPI_STRING , ,options); |
268 |
root |
1.15 |
hv_context (CFAPI_STRING , ,extension); |
269 |
root |
1.1 |
|
270 |
root |
1.15 |
XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
271 |
root |
1.1 |
|
272 |
|
|
PUTBACK; |
273 |
root |
1.15 |
int count = call_pv (func, G_SCALAR | G_EVAL); |
274 |
root |
1.1 |
SPAGAIN; |
275 |
|
|
|
276 |
root |
1.6 |
if (SvTRUE (ERRSV)) |
277 |
|
|
LOG (llevError, "event '%d' callback evaluation error: %s", context->event_code, SvPV_nolen (ERRSV)); |
278 |
|
|
|
279 |
root |
1.1 |
context->returnvalue = count > 0 ? POPi : 0; |
280 |
|
|
|
281 |
|
|
PUTBACK; |
282 |
|
|
FREETMPS; |
283 |
|
|
LEAVE; |
284 |
|
|
} |
285 |
|
|
|
286 |
|
|
///////////////////////////////////////////////////////////////////////////// |
287 |
|
|
|
288 |
|
|
int |
289 |
|
|
initPlugin (const char *iversion, f_plug_api gethooksptr) |
290 |
|
|
{ |
291 |
|
|
gethook = gethooksptr; |
292 |
|
|
printf (PLUGIN_VERSION " init\n"); |
293 |
|
|
|
294 |
|
|
return 0; |
295 |
|
|
} |
296 |
|
|
|
297 |
|
|
static CommArray_s rtn_cmd; |
298 |
|
|
|
299 |
|
|
int |
300 |
|
|
runPluginCommand (object *obj, char *params) |
301 |
|
|
{ |
302 |
|
|
dSP; |
303 |
|
|
|
304 |
|
|
ENTER; |
305 |
|
|
SAVETMPS; |
306 |
|
|
|
307 |
|
|
PUSHMARK (SP); |
308 |
|
|
|
309 |
|
|
EXTEND (SP, 3); |
310 |
|
|
PUSHs (sv_2mortal (newSVpv (rtn_cmd.name, 0))); |
311 |
|
|
PUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, obj))); |
312 |
|
|
|
313 |
|
|
if (params) |
314 |
|
|
PUSHs (sv_2mortal (newSVpv (params, 0))); |
315 |
|
|
|
316 |
|
|
PUTBACK; |
317 |
|
|
int count = call_pv ("cf::inject_command", G_SCALAR | G_EVAL); |
318 |
|
|
SPAGAIN; |
319 |
|
|
|
320 |
root |
1.6 |
if (SvTRUE (ERRSV)) |
321 |
|
|
LOG (llevError, "command '%s' callback evaluation error: %s", rtn_cmd.name, SvPV_nolen (ERRSV)); |
322 |
|
|
|
323 |
root |
1.1 |
int returnvalue = count > 0 ? POPi : -1; |
324 |
|
|
|
325 |
|
|
PUTBACK; |
326 |
|
|
FREETMPS; |
327 |
|
|
LEAVE; |
328 |
|
|
|
329 |
|
|
return returnvalue; |
330 |
|
|
} |
331 |
|
|
|
332 |
|
|
void * |
333 |
|
|
getPluginProperty (int *type, ...) |
334 |
|
|
{ |
335 |
|
|
va_list args; |
336 |
|
|
char *propname; |
337 |
|
|
int i; |
338 |
|
|
va_start (args, type); |
339 |
|
|
propname = va_arg (args, char *); |
340 |
|
|
//printf ("Property name: %s\n", propname); |
341 |
root |
1.3 |
|
342 |
root |
1.1 |
if (!strcmp (propname, "command?")) |
343 |
|
|
{ |
344 |
root |
1.3 |
if (!perl) |
345 |
|
|
return NULL; |
346 |
|
|
|
347 |
root |
1.1 |
const char *cmdname = va_arg (args, const char *); |
348 |
|
|
HV *hv = get_hv ("cf::COMMAND", 1); |
349 |
|
|
SV **svp = hv_fetch (hv, cmdname, strlen (cmdname) + 1, 0); |
350 |
|
|
|
351 |
|
|
va_end (args); |
352 |
|
|
|
353 |
|
|
if (svp) |
354 |
|
|
{ |
355 |
|
|
// this is totaly broken, should stash it into %COMMAND |
356 |
|
|
rtn_cmd.name = cmdname; |
357 |
|
|
rtn_cmd.time = SvNV (*svp); |
358 |
|
|
rtn_cmd.func = runPluginCommand; |
359 |
|
|
|
360 |
|
|
return &rtn_cmd; |
361 |
|
|
} |
362 |
|
|
} |
363 |
|
|
else if (!strcmp (propname, "Identification")) |
364 |
|
|
{ |
365 |
|
|
va_end (args); |
366 |
|
|
return PLUGIN_NAME; |
367 |
|
|
} |
368 |
|
|
else if (!strcmp (propname, "FullName")) |
369 |
|
|
{ |
370 |
|
|
va_end (args); |
371 |
|
|
return PLUGIN_VERSION; |
372 |
|
|
} |
373 |
|
|
else |
374 |
|
|
va_end (args); |
375 |
|
|
|
376 |
|
|
return NULL; |
377 |
|
|
} |
378 |
|
|
|
379 |
|
|
void *globalEventListener (int *type, ...); |
380 |
|
|
|
381 |
|
|
int |
382 |
|
|
postInitPlugin () |
383 |
|
|
{ |
384 |
|
|
int hooktype = 1; |
385 |
|
|
int rtype = 0; |
386 |
|
|
|
387 |
|
|
printf (PLUGIN_VERSION " post init\n"); |
388 |
|
|
|
389 |
|
|
registerGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_register_global_event"); |
390 |
|
|
unregisterGlobalEvent = gethook (&rtype, hooktype, "cfapi_system_unregister_global_event"); |
391 |
|
|
systemDirectory = gethook (&rtype, hooktype, "cfapi_system_directory"); |
392 |
root |
1.10 |
object_set_property = gethook (&rtype, hooktype, "cfapi_object_set_property"); |
393 |
root |
1.11 |
map_get_map = gethook (&rtype, hooktype, "cfapi_map_get_map"); |
394 |
|
|
|
395 |
root |
1.1 |
cf_init_plugin (gethook); |
396 |
|
|
|
397 |
|
|
/* Pick the global events you want to monitor from this plugin */ |
398 |
|
|
registerGlobalEvent (NULL, EVENT_BORN, PLUGIN_NAME, globalEventListener); |
399 |
|
|
registerGlobalEvent (NULL, EVENT_CLOCK, PLUGIN_NAME, globalEventListener); |
400 |
|
|
//registerGlobalEvent (NULL, EVENT_CRASH, PLUGIN_NAME, globalEventListener); |
401 |
|
|
registerGlobalEvent (NULL, EVENT_PLAYER_DEATH, PLUGIN_NAME, globalEventListener); |
402 |
|
|
registerGlobalEvent (NULL, EVENT_GKILL, PLUGIN_NAME, globalEventListener); |
403 |
|
|
registerGlobalEvent (NULL, EVENT_LOGIN, PLUGIN_NAME, globalEventListener); |
404 |
|
|
registerGlobalEvent (NULL, EVENT_LOGOUT, PLUGIN_NAME, globalEventListener); |
405 |
|
|
registerGlobalEvent (NULL, EVENT_MAPENTER, PLUGIN_NAME, globalEventListener); |
406 |
|
|
registerGlobalEvent (NULL, EVENT_MAPLEAVE, PLUGIN_NAME, globalEventListener); |
407 |
|
|
registerGlobalEvent (NULL, EVENT_MAPRESET, PLUGIN_NAME, globalEventListener); |
408 |
|
|
registerGlobalEvent (NULL, EVENT_REMOVE, PLUGIN_NAME, globalEventListener); |
409 |
|
|
registerGlobalEvent (NULL, EVENT_SHOUT, PLUGIN_NAME, globalEventListener); |
410 |
|
|
registerGlobalEvent (NULL, EVENT_TELL, PLUGIN_NAME, globalEventListener); |
411 |
|
|
registerGlobalEvent (NULL, EVENT_MUZZLE, PLUGIN_NAME, globalEventListener); |
412 |
|
|
registerGlobalEvent (NULL, EVENT_KICK, PLUGIN_NAME, globalEventListener); |
413 |
root |
1.14 |
registerGlobalEvent (NULL, EVENT_FREE_OB, PLUGIN_NAME, globalEventListener); |
414 |
root |
1.1 |
|
415 |
|
|
char *argv[] = { |
416 |
|
|
"", |
417 |
|
|
"-e" |
418 |
|
|
"BEGIN {" |
419 |
|
|
" cf->bootstrap;" |
420 |
root |
1.5 |
" unshift @INC, cf::datadir ();" |
421 |
root |
1.1 |
"}" |
422 |
|
|
"" |
423 |
|
|
"use cf;" |
424 |
|
|
}; |
425 |
|
|
|
426 |
|
|
perl = perl_alloc (); |
427 |
|
|
perl_construct (perl); |
428 |
|
|
|
429 |
root |
1.5 |
if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) || perl_run (perl)) |
430 |
root |
1.1 |
{ |
431 |
|
|
printf ("unable to initialize perl-interpreter, continuing without.\n"); |
432 |
|
|
|
433 |
|
|
perl_destruct (perl); |
434 |
|
|
perl_free (perl); |
435 |
|
|
perl = 0; |
436 |
|
|
} |
437 |
root |
1.14 |
else |
438 |
|
|
{ |
439 |
|
|
obj_cache = newHV (); |
440 |
|
|
} |
441 |
root |
1.1 |
|
442 |
|
|
return 0; |
443 |
|
|
} |
444 |
|
|
|
445 |
|
|
void * |
446 |
|
|
globalEventListener (int *type, ...) |
447 |
|
|
{ |
448 |
|
|
va_list args; |
449 |
|
|
static int rv = 0; |
450 |
|
|
CFPContext context; |
451 |
|
|
char *buf; |
452 |
|
|
player *pl; |
453 |
|
|
object *op; |
454 |
|
|
|
455 |
|
|
if (!perl) |
456 |
|
|
return; |
457 |
|
|
|
458 |
|
|
memset (&context, 0, sizeof (context)); |
459 |
|
|
|
460 |
|
|
va_start (args, type); |
461 |
|
|
context.event_code = va_arg (args, int); |
462 |
|
|
|
463 |
|
|
switch (context.event_code) |
464 |
|
|
{ |
465 |
|
|
case EVENT_CRASH: |
466 |
|
|
printf ("Unimplemented for now\n"); |
467 |
|
|
break; |
468 |
|
|
|
469 |
root |
1.14 |
case EVENT_MAPENTER: |
470 |
|
|
case EVENT_MAPLEAVE: |
471 |
|
|
case EVENT_FREE_OB: |
472 |
root |
1.1 |
case EVENT_BORN: |
473 |
root |
1.14 |
case EVENT_REMOVE: |
474 |
root |
1.1 |
context.activator = va_arg (args, object *); |
475 |
|
|
break; |
476 |
|
|
|
477 |
|
|
case EVENT_PLAYER_DEATH: |
478 |
|
|
context.who = va_arg (args, object *); |
479 |
|
|
break; |
480 |
|
|
|
481 |
|
|
case EVENT_GKILL: |
482 |
|
|
context.who = va_arg (args, object *); |
483 |
|
|
context.activator = va_arg (args, object *); |
484 |
|
|
break; |
485 |
|
|
|
486 |
|
|
case EVENT_LOGIN: |
487 |
|
|
case EVENT_LOGOUT: |
488 |
|
|
pl = va_arg (args, player *); |
489 |
|
|
context.activator = pl->ob; |
490 |
|
|
buf = va_arg (args, char *); |
491 |
|
|
if (buf != 0) |
492 |
root |
1.15 |
strncpy (context.message, buf, sizeof (context.message)); |
493 |
root |
1.1 |
break; |
494 |
|
|
|
495 |
|
|
case EVENT_SHOUT: |
496 |
|
|
case EVENT_MUZZLE: |
497 |
|
|
case EVENT_KICK: |
498 |
|
|
context.activator = va_arg (args, object *); |
499 |
|
|
buf = va_arg (args, char *); |
500 |
|
|
if (buf != 0) |
501 |
root |
1.15 |
strncpy (context.message, buf, sizeof (context.message)); |
502 |
root |
1.1 |
break; |
503 |
|
|
|
504 |
root |
1.14 |
case EVENT_CLOCK: |
505 |
|
|
clean_obj_cache (); |
506 |
root |
1.1 |
break; |
507 |
|
|
|
508 |
root |
1.14 |
case EVENT_TELL: |
509 |
root |
1.1 |
break; |
510 |
|
|
|
511 |
|
|
case EVENT_MAPRESET: |
512 |
|
|
buf = va_arg (args, char *); |
513 |
|
|
if (buf != 0) |
514 |
root |
1.15 |
strncpy (context.message, buf, sizeof (context.message)); |
515 |
root |
1.1 |
break; |
516 |
|
|
} |
517 |
|
|
|
518 |
|
|
va_end (args); |
519 |
|
|
|
520 |
root |
1.14 |
if (context.event_code == EVENT_FREE_OB) |
521 |
|
|
{ |
522 |
|
|
SV *sv = hv_delete (obj_cache, (char *)&context.activator, sizeof (object *), 0); |
523 |
|
|
|
524 |
|
|
if (sv) |
525 |
|
|
{ |
526 |
|
|
clearSVptr (sv); |
527 |
|
|
SvREFCNT_dec (sv); |
528 |
|
|
} |
529 |
|
|
} |
530 |
|
|
else |
531 |
root |
1.15 |
inject_event ("cf::inject_global_event", &context); |
532 |
root |
1.1 |
|
533 |
|
|
rv = context.returnvalue; |
534 |
|
|
|
535 |
|
|
return &rv; |
536 |
|
|
} |
537 |
|
|
|
538 |
|
|
void * |
539 |
|
|
eventListener (int *type, ...) |
540 |
|
|
{ |
541 |
|
|
static int rv = 0; |
542 |
|
|
va_list args; |
543 |
|
|
char *buf; |
544 |
|
|
CFPContext context; |
545 |
|
|
|
546 |
|
|
if (!perl) |
547 |
|
|
return; |
548 |
|
|
|
549 |
|
|
memset (&context, 0, sizeof (context)); |
550 |
|
|
|
551 |
|
|
va_start (args, type); |
552 |
|
|
|
553 |
|
|
context.who = va_arg (args, object *); |
554 |
|
|
context.event_code = va_arg (args, int); |
555 |
|
|
context.activator = va_arg (args, object *); |
556 |
|
|
context.third = va_arg (args, object *); |
557 |
root |
1.15 |
|
558 |
root |
1.1 |
buf = va_arg (args, char *); |
559 |
|
|
if (buf != 0) |
560 |
root |
1.15 |
strncpy (context.message, buf, sizeof (context.message)); |
561 |
root |
1.1 |
|
562 |
|
|
context.fix = va_arg (args, int); |
563 |
root |
1.15 |
strncpy (context.extension, va_arg (args, char *), sizeof (context.extension)); |
564 |
|
|
strncpy (context.options, va_arg (args, char *), sizeof (context.options)); |
565 |
root |
1.1 |
context.returnvalue = 0; |
566 |
|
|
va_end (args); |
567 |
|
|
|
568 |
root |
1.15 |
inject_event ("cf::inject_event", &context); |
569 |
root |
1.1 |
|
570 |
|
|
rv = context.returnvalue; |
571 |
|
|
return &rv; |
572 |
|
|
} |
573 |
|
|
|
574 |
|
|
int |
575 |
|
|
closePlugin () |
576 |
|
|
{ |
577 |
|
|
printf (PLUGIN_VERSION " closing\n"); |
578 |
|
|
|
579 |
|
|
if (perl) |
580 |
|
|
{ |
581 |
|
|
perl_destruct (perl); |
582 |
|
|
perl_free (perl); |
583 |
|
|
perl = 0; |
584 |
|
|
} |
585 |
|
|
|
586 |
|
|
return 0; |
587 |
|
|
} |
588 |
|
|
|
589 |
|
|
MODULE = cf PACKAGE = cf PREFIX = cf_ |
590 |
|
|
|
591 |
|
|
BOOT: |
592 |
|
|
{ |
593 |
|
|
HV *stash = gv_stashpv ("cf", 1); |
594 |
|
|
|
595 |
root |
1.9 |
static const struct { |
596 |
root |
1.1 |
const char *name; |
597 |
|
|
IV iv; |
598 |
|
|
} *civ, const_iv[] = { |
599 |
|
|
# define const_iv(name) { # name, (IV)name }, |
600 |
|
|
const_iv (llevError) |
601 |
|
|
const_iv (llevInfo) |
602 |
|
|
const_iv (llevDebug) |
603 |
|
|
const_iv (llevMonster) |
604 |
|
|
|
605 |
|
|
const_iv (PLAYER) |
606 |
|
|
const_iv (ROD) |
607 |
|
|
const_iv (TREASURE) |
608 |
|
|
const_iv (POTION) |
609 |
|
|
const_iv (FOOD) |
610 |
|
|
const_iv (POISON) |
611 |
|
|
const_iv (BOOK) |
612 |
|
|
const_iv (CLOCK) |
613 |
|
|
const_iv (LIGHTNING) |
614 |
|
|
const_iv (ARROW) |
615 |
|
|
const_iv (BOW) |
616 |
|
|
const_iv (WEAPON) |
617 |
|
|
const_iv (ARMOUR) |
618 |
|
|
const_iv (PEDESTAL) |
619 |
|
|
const_iv (ALTAR) |
620 |
|
|
const_iv (CONFUSION) |
621 |
|
|
const_iv (LOCKED_DOOR) |
622 |
|
|
const_iv (SPECIAL_KEY) |
623 |
|
|
const_iv (MAP) |
624 |
|
|
const_iv (DOOR) |
625 |
|
|
const_iv (KEY) |
626 |
|
|
const_iv (TIMED_GATE) |
627 |
|
|
const_iv (TRIGGER) |
628 |
|
|
const_iv (GRIMREAPER) |
629 |
|
|
const_iv (MAGIC_EAR) |
630 |
|
|
const_iv (TRIGGER_BUTTON) |
631 |
|
|
const_iv (TRIGGER_ALTAR) |
632 |
|
|
const_iv (TRIGGER_PEDESTAL) |
633 |
|
|
const_iv (SHIELD) |
634 |
|
|
const_iv (HELMET) |
635 |
|
|
const_iv (HORN) |
636 |
|
|
const_iv (MONEY) |
637 |
|
|
const_iv (CLASS) |
638 |
|
|
const_iv (GRAVESTONE) |
639 |
|
|
const_iv (AMULET) |
640 |
|
|
const_iv (PLAYERMOVER) |
641 |
|
|
const_iv (TELEPORTER) |
642 |
|
|
const_iv (CREATOR) |
643 |
|
|
const_iv (SKILL) |
644 |
|
|
const_iv (EXPERIENCE) |
645 |
|
|
const_iv (EARTHWALL) |
646 |
|
|
const_iv (GOLEM) |
647 |
|
|
const_iv (THROWN_OBJ) |
648 |
|
|
const_iv (BLINDNESS) |
649 |
|
|
const_iv (GOD) |
650 |
|
|
const_iv (DETECTOR) |
651 |
|
|
const_iv (TRIGGER_MARKER) |
652 |
|
|
const_iv (DEAD_OBJECT) |
653 |
|
|
const_iv (DRINK) |
654 |
|
|
const_iv (MARKER) |
655 |
|
|
const_iv (HOLY_ALTAR) |
656 |
|
|
const_iv (PLAYER_CHANGER) |
657 |
|
|
const_iv (BATTLEGROUND) |
658 |
|
|
const_iv (PEACEMAKER) |
659 |
|
|
const_iv (GEM) |
660 |
|
|
const_iv (FIREWALL) |
661 |
|
|
const_iv (ANVIL) |
662 |
|
|
const_iv (CHECK_INV) |
663 |
|
|
const_iv (MOOD_FLOOR) |
664 |
|
|
const_iv (EXIT) |
665 |
|
|
const_iv (ENCOUNTER) |
666 |
|
|
const_iv (SHOP_FLOOR) |
667 |
|
|
const_iv (SHOP_MAT) |
668 |
|
|
const_iv (RING) |
669 |
|
|
const_iv (FLOOR) |
670 |
|
|
const_iv (FLESH) |
671 |
|
|
const_iv (INORGANIC) |
672 |
|
|
const_iv (SKILL_TOOL) |
673 |
|
|
const_iv (LIGHTER) |
674 |
|
|
const_iv (TRAP_PART) |
675 |
|
|
const_iv (WALL) |
676 |
|
|
const_iv (LIGHT_SOURCE) |
677 |
|
|
const_iv (MISC_OBJECT) |
678 |
|
|
const_iv (MONSTER) |
679 |
|
|
const_iv (SPAWN_GENERATOR) |
680 |
|
|
const_iv (LAMP) |
681 |
|
|
const_iv (DUPLICATOR) |
682 |
|
|
const_iv (TOOL) |
683 |
|
|
const_iv (SPELLBOOK) |
684 |
|
|
const_iv (BUILDFAC) |
685 |
|
|
const_iv (CLOAK) |
686 |
|
|
const_iv (SPINNER) |
687 |
|
|
const_iv (GATE) |
688 |
|
|
const_iv (BUTTON) |
689 |
|
|
const_iv (CF_HANDLE) |
690 |
|
|
const_iv (HOLE) |
691 |
|
|
const_iv (TRAPDOOR) |
692 |
|
|
const_iv (SIGN) |
693 |
|
|
const_iv (BOOTS) |
694 |
|
|
const_iv (GLOVES) |
695 |
|
|
const_iv (SPELL) |
696 |
|
|
const_iv (SPELL_EFFECT) |
697 |
|
|
const_iv (CONVERTER) |
698 |
|
|
const_iv (BRACERS) |
699 |
|
|
const_iv (POISONING) |
700 |
|
|
const_iv (SAVEBED) |
701 |
|
|
const_iv (POISONCLOUD) |
702 |
|
|
const_iv (FIREHOLES) |
703 |
|
|
const_iv (WAND) |
704 |
|
|
const_iv (SCROLL) |
705 |
|
|
const_iv (DIRECTOR) |
706 |
|
|
const_iv (GIRDLE) |
707 |
|
|
const_iv (FORCE) |
708 |
|
|
const_iv (POTION_EFFECT) |
709 |
|
|
const_iv (EVENT_CONNECTOR) |
710 |
|
|
const_iv (CLOSE_CON) |
711 |
|
|
const_iv (CONTAINER) |
712 |
|
|
const_iv (ARMOUR_IMPROVER) |
713 |
|
|
const_iv (WEAPON_IMPROVER) |
714 |
|
|
const_iv (SKILLSCROLL) |
715 |
|
|
const_iv (DEEP_SWAMP) |
716 |
|
|
const_iv (IDENTIFY_ALTAR) |
717 |
|
|
const_iv (MENU) |
718 |
|
|
const_iv (RUNE) |
719 |
|
|
const_iv (TRAP) |
720 |
|
|
const_iv (POWER_CRYSTAL) |
721 |
|
|
const_iv (CORPSE) |
722 |
|
|
const_iv (DISEASE) |
723 |
|
|
const_iv (SYMPTOM) |
724 |
|
|
const_iv (BUILDER) |
725 |
|
|
const_iv (MATERIAL) |
726 |
|
|
const_iv (ITEM_TRANSFORMER) |
727 |
|
|
const_iv (QUEST) |
728 |
|
|
|
729 |
|
|
const_iv (ST_BD_BUILD) |
730 |
|
|
const_iv (ST_BD_REMOVE) |
731 |
|
|
const_iv (ST_MAT_FLOOR) |
732 |
|
|
const_iv (ST_MAT_WALL) |
733 |
|
|
const_iv (ST_MAT_ITEM) |
734 |
|
|
|
735 |
|
|
const_iv (QUEST_IN_PROGRESS) |
736 |
|
|
const_iv (QUEST_DONE_QUEST) |
737 |
|
|
const_iv (QUEST_DONE_TASK) |
738 |
|
|
const_iv (QUEST_START_QUEST) |
739 |
|
|
const_iv (QUEST_END_QUEST) |
740 |
|
|
const_iv (QUEST_START_TASK) |
741 |
|
|
const_iv (QUEST_END_TASK) |
742 |
|
|
const_iv (QUEST_OVERRIDE) |
743 |
|
|
const_iv (QUEST_ON_ACTIVATE) |
744 |
|
|
|
745 |
|
|
const_iv (WEAP_HIT) |
746 |
|
|
const_iv (WEAP_SLASH) |
747 |
|
|
const_iv (WEAP_PIERCE) |
748 |
|
|
const_iv (WEAP_CLEAVE) |
749 |
|
|
const_iv (WEAP_SLICE) |
750 |
|
|
const_iv (WEAP_STAB) |
751 |
|
|
const_iv (WEAP_WHIP) |
752 |
|
|
const_iv (WEAP_CRUSH) |
753 |
|
|
const_iv (WEAP_BLUD) |
754 |
|
|
|
755 |
|
|
const_iv (FLAG_ALIVE) |
756 |
|
|
const_iv (FLAG_WIZ) |
757 |
|
|
const_iv (FLAG_REMOVED) |
758 |
|
|
const_iv (FLAG_FREED) |
759 |
|
|
const_iv (FLAG_WAS_WIZ) |
760 |
|
|
const_iv (FLAG_APPLIED) |
761 |
|
|
const_iv (FLAG_UNPAID) |
762 |
|
|
const_iv (FLAG_USE_SHIELD) |
763 |
|
|
const_iv (FLAG_NO_PICK) |
764 |
|
|
const_iv (FLAG_ANIMATE) |
765 |
|
|
const_iv (FLAG_MONSTER) |
766 |
|
|
const_iv (FLAG_FRIENDLY) |
767 |
|
|
const_iv (FLAG_GENERATOR) |
768 |
|
|
const_iv (FLAG_IS_THROWN) |
769 |
|
|
const_iv (FLAG_AUTO_APPLY) |
770 |
|
|
const_iv (FLAG_TREASURE) |
771 |
|
|
const_iv (FLAG_PLAYER_SOLD) |
772 |
|
|
const_iv (FLAG_SEE_INVISIBLE) |
773 |
|
|
const_iv (FLAG_CAN_ROLL) |
774 |
|
|
const_iv (FLAG_OVERLAY_FLOOR) |
775 |
|
|
const_iv (FLAG_IS_TURNABLE) |
776 |
|
|
const_iv (FLAG_IS_USED_UP) |
777 |
|
|
const_iv (FLAG_IDENTIFIED) |
778 |
|
|
const_iv (FLAG_REFLECTING) |
779 |
|
|
const_iv (FLAG_CHANGING) |
780 |
|
|
const_iv (FLAG_SPLITTING) |
781 |
|
|
const_iv (FLAG_HITBACK) |
782 |
|
|
const_iv (FLAG_STARTEQUIP) |
783 |
|
|
const_iv (FLAG_BLOCKSVIEW) |
784 |
|
|
const_iv (FLAG_UNDEAD) |
785 |
|
|
const_iv (FLAG_SCARED) |
786 |
|
|
const_iv (FLAG_UNAGGRESSIVE) |
787 |
|
|
const_iv (FLAG_REFL_MISSILE) |
788 |
|
|
const_iv (FLAG_REFL_SPELL) |
789 |
|
|
const_iv (FLAG_NO_MAGIC) |
790 |
|
|
const_iv (FLAG_NO_FIX_PLAYER) |
791 |
|
|
const_iv (FLAG_IS_LIGHTABLE) |
792 |
|
|
const_iv (FLAG_TEAR_DOWN) |
793 |
|
|
const_iv (FLAG_RUN_AWAY) |
794 |
|
|
const_iv (FLAG_PICK_UP) |
795 |
|
|
const_iv (FLAG_UNIQUE) |
796 |
|
|
const_iv (FLAG_NO_DROP) |
797 |
|
|
const_iv (FLAG_WIZCAST) |
798 |
|
|
const_iv (FLAG_CAST_SPELL) |
799 |
|
|
const_iv (FLAG_USE_SCROLL) |
800 |
|
|
const_iv (FLAG_USE_RANGE) |
801 |
|
|
const_iv (FLAG_USE_BOW) |
802 |
|
|
const_iv (FLAG_USE_ARMOUR) |
803 |
|
|
const_iv (FLAG_USE_WEAPON) |
804 |
|
|
const_iv (FLAG_USE_RING) |
805 |
|
|
const_iv (FLAG_READY_RANGE) |
806 |
|
|
const_iv (FLAG_READY_BOW) |
807 |
|
|
const_iv (FLAG_XRAYS) |
808 |
|
|
const_iv (FLAG_NO_APPLY) |
809 |
|
|
const_iv (FLAG_IS_FLOOR) |
810 |
|
|
const_iv (FLAG_LIFESAVE) |
811 |
|
|
const_iv (FLAG_NO_STRENGTH) |
812 |
|
|
const_iv (FLAG_SLEEP) |
813 |
|
|
const_iv (FLAG_STAND_STILL) |
814 |
|
|
const_iv (FLAG_RANDOM_MOVE) |
815 |
|
|
const_iv (FLAG_ONLY_ATTACK) |
816 |
|
|
const_iv (FLAG_CONFUSED) |
817 |
|
|
const_iv (FLAG_STEALTH) |
818 |
|
|
const_iv (FLAG_WIZPASS) |
819 |
|
|
const_iv (FLAG_IS_LINKED) |
820 |
|
|
const_iv (FLAG_CURSED) |
821 |
|
|
const_iv (FLAG_DAMNED) |
822 |
|
|
const_iv (FLAG_SEE_ANYWHERE) |
823 |
|
|
const_iv (FLAG_KNOWN_MAGICAL) |
824 |
|
|
const_iv (FLAG_KNOWN_CURSED) |
825 |
|
|
const_iv (FLAG_CAN_USE_SKILL) |
826 |
|
|
const_iv (FLAG_BEEN_APPLIED) |
827 |
|
|
const_iv (FLAG_READY_SCROLL) |
828 |
|
|
const_iv (FLAG_USE_ROD) |
829 |
|
|
const_iv (FLAG_USE_HORN) |
830 |
|
|
const_iv (FLAG_MAKE_INVIS) |
831 |
|
|
const_iv (FLAG_INV_LOCKED) |
832 |
|
|
const_iv (FLAG_IS_WOODED) |
833 |
|
|
const_iv (FLAG_IS_HILLY) |
834 |
|
|
const_iv (FLAG_READY_SKILL) |
835 |
|
|
const_iv (FLAG_READY_WEAPON) |
836 |
|
|
const_iv (FLAG_NO_SKILL_IDENT) |
837 |
|
|
const_iv (FLAG_BLIND) |
838 |
|
|
const_iv (FLAG_SEE_IN_DARK) |
839 |
|
|
const_iv (FLAG_IS_CAULDRON) |
840 |
|
|
const_iv (FLAG_NO_STEAL) |
841 |
|
|
const_iv (FLAG_ONE_HIT) |
842 |
|
|
const_iv (FLAG_CLIENT_SENT) |
843 |
|
|
const_iv (FLAG_BERSERK) |
844 |
|
|
const_iv (FLAG_NEUTRAL) |
845 |
|
|
const_iv (FLAG_NO_ATTACK) |
846 |
|
|
const_iv (FLAG_NO_DAMAGE) |
847 |
|
|
const_iv (FLAG_OBJ_ORIGINAL) |
848 |
|
|
const_iv (FLAG_OBJ_SAVE_ON_OVL) |
849 |
|
|
const_iv (FLAG_ACTIVATE_ON_PUSH) |
850 |
|
|
const_iv (FLAG_ACTIVATE_ON_RELEASE) |
851 |
|
|
const_iv (FLAG_IS_WATER) |
852 |
|
|
const_iv (FLAG_CONTENT_ON_GEN) |
853 |
|
|
const_iv (FLAG_IS_A_TEMPLATE) |
854 |
|
|
const_iv (FLAG_IS_BUILDABLE) |
855 |
|
|
const_iv (FLAG_AFK) |
856 |
root |
1.6 |
|
857 |
|
|
const_iv (NDI_BLACK) |
858 |
|
|
const_iv (NDI_WHITE) |
859 |
|
|
const_iv (NDI_NAVY) |
860 |
|
|
const_iv (NDI_RED) |
861 |
|
|
const_iv (NDI_ORANGE) |
862 |
|
|
const_iv (NDI_BLUE) |
863 |
|
|
const_iv (NDI_DK_ORANGE) |
864 |
|
|
const_iv (NDI_GREEN) |
865 |
|
|
const_iv (NDI_LT_GREEN) |
866 |
|
|
const_iv (NDI_GREY) |
867 |
|
|
const_iv (NDI_BROWN) |
868 |
|
|
const_iv (NDI_GOLD) |
869 |
|
|
const_iv (NDI_TAN) |
870 |
|
|
const_iv (NDI_MAX_COLOR) |
871 |
|
|
const_iv (NDI_COLOR_MASK) |
872 |
|
|
const_iv (NDI_UNIQUE) |
873 |
|
|
const_iv (NDI_ALL) |
874 |
|
|
|
875 |
|
|
const_iv (F_APPLIED) |
876 |
|
|
const_iv (F_LOCATION) |
877 |
|
|
const_iv (F_UNPAID) |
878 |
|
|
const_iv (F_MAGIC) |
879 |
|
|
const_iv (F_CURSED) |
880 |
|
|
const_iv (F_DAMNED) |
881 |
|
|
const_iv (F_OPEN) |
882 |
|
|
const_iv (F_NOPICK) |
883 |
|
|
const_iv (F_LOCKED) |
884 |
root |
1.11 |
|
885 |
|
|
const_iv (P_BLOCKSVIEW) |
886 |
|
|
const_iv (P_NO_MAGIC) |
887 |
|
|
const_iv (P_IS_ALIVE) |
888 |
|
|
const_iv (P_NO_CLERIC) |
889 |
|
|
const_iv (P_NEED_UPDATE) |
890 |
|
|
const_iv (P_NO_ERROR) |
891 |
|
|
const_iv (P_OUT_OF_MAP) |
892 |
|
|
const_iv (P_NEW_MAP) |
893 |
root |
1.14 |
|
894 |
|
|
const_iv (UP_OBJ_INSERT) |
895 |
|
|
const_iv (UP_OBJ_REMOVE) |
896 |
|
|
const_iv (UP_OBJ_CHANGE) |
897 |
|
|
const_iv (UP_OBJ_FACE) |
898 |
|
|
|
899 |
|
|
const_iv (INS_NO_MERGE) |
900 |
|
|
const_iv (INS_ABOVE_FLOOR_ONLY) |
901 |
|
|
const_iv (INS_NO_WALK_ON) |
902 |
|
|
const_iv (INS_ON_TOP) |
903 |
|
|
const_iv (INS_BELOW_ORIGINATOR) |
904 |
|
|
const_iv (INS_MAP_LOAD) |
905 |
|
|
|
906 |
|
|
const_iv (WILL_APPLY_HANDLE) |
907 |
|
|
const_iv (WILL_APPLY_TREASURE) |
908 |
|
|
const_iv (WILL_APPLY_EARTHWALL) |
909 |
|
|
const_iv (WILL_APPLY_DOOR) |
910 |
|
|
const_iv (WILL_APPLY_FOOD) |
911 |
root |
1.1 |
}; |
912 |
|
|
|
913 |
|
|
for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
914 |
|
|
newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
915 |
|
|
|
916 |
root |
1.9 |
static const struct { |
917 |
root |
1.1 |
const char *name; |
918 |
|
|
IV iv; |
919 |
|
|
} *event, event_list[] = { |
920 |
|
|
# define const_event(name) { # name, (IV)EVENT_ ## name }, |
921 |
|
|
const_event (NONE) |
922 |
|
|
const_event (APPLY) |
923 |
|
|
const_event (ATTACK) |
924 |
|
|
const_event (DEATH) |
925 |
|
|
const_event (DROP) |
926 |
|
|
const_event (PICKUP) |
927 |
|
|
const_event (SAY) |
928 |
|
|
const_event (STOP) |
929 |
|
|
const_event (TIME) |
930 |
|
|
const_event (THROW) |
931 |
|
|
const_event (TRIGGER) |
932 |
|
|
const_event (CLOSE) |
933 |
|
|
const_event (TIMER) |
934 |
root |
1.14 |
const_event (MOVE) |
935 |
root |
1.1 |
|
936 |
|
|
const_event (BORN) |
937 |
|
|
const_event (CLOCK) |
938 |
|
|
const_event (CRASH) |
939 |
|
|
const_event (PLAYER_DEATH) |
940 |
|
|
const_event (GKILL) |
941 |
|
|
const_event (LOGIN) |
942 |
|
|
const_event (LOGOUT) |
943 |
|
|
const_event (MAPENTER) |
944 |
|
|
const_event (MAPLEAVE) |
945 |
|
|
const_event (MAPRESET) |
946 |
|
|
const_event (REMOVE) |
947 |
|
|
const_event (SHOUT) |
948 |
|
|
const_event (TELL) |
949 |
|
|
const_event (MUZZLE) |
950 |
|
|
const_event (KICK) |
951 |
root |
1.14 |
//const_event (FREE_OB) |
952 |
root |
1.1 |
}; |
953 |
|
|
|
954 |
|
|
AV *av = get_av ("cf::EVENT", 1); |
955 |
|
|
|
956 |
|
|
for (event = event_list + sizeof (event_list) / sizeof (event_list [0]); event-- > event_list; ) |
957 |
|
|
av_store (av, event->iv, newSVpv ((char *)event->name, 0)); |
958 |
|
|
|
959 |
root |
1.9 |
static const struct { |
960 |
root |
1.1 |
int dtype; |
961 |
|
|
const char *name; |
962 |
|
|
IV idx; |
963 |
|
|
} *cprop, prop_table[] = { |
964 |
|
|
# define prop(type, name) { type, # name, (IV) CFAPI_ ## name }, |
965 |
|
|
prop (CFAPI_INT, MAP_PROP_FLAGS) |
966 |
|
|
prop (CFAPI_INT, MAP_PROP_DIFFICULTY) |
967 |
|
|
prop (CFAPI_STRING, MAP_PROP_PATH) |
968 |
|
|
prop (CFAPI_STRING, MAP_PROP_TMPNAME) |
969 |
|
|
prop (CFAPI_STRING, MAP_PROP_NAME) |
970 |
|
|
prop (CFAPI_INT, MAP_PROP_RESET_TIME) |
971 |
|
|
prop (CFAPI_INT, MAP_PROP_RESET_TIMEOUT) |
972 |
|
|
prop (CFAPI_INT, MAP_PROP_PLAYERS) |
973 |
|
|
prop (CFAPI_INT, MAP_PROP_DARKNESS) |
974 |
|
|
prop (CFAPI_INT, MAP_PROP_WIDTH) |
975 |
|
|
prop (CFAPI_INT, MAP_PROP_HEIGHT) |
976 |
|
|
prop (CFAPI_INT, MAP_PROP_ENTER_X) |
977 |
|
|
prop (CFAPI_INT, MAP_PROP_ENTER_Y) |
978 |
|
|
prop (CFAPI_INT, MAP_PROP_TEMPERATURE) |
979 |
|
|
prop (CFAPI_INT, MAP_PROP_PRESSURE) |
980 |
|
|
prop (CFAPI_INT, MAP_PROP_HUMIDITY) |
981 |
|
|
prop (CFAPI_INT, MAP_PROP_WINDSPEED) |
982 |
|
|
prop (CFAPI_INT, MAP_PROP_WINDDIR) |
983 |
|
|
prop (CFAPI_INT, MAP_PROP_SKY) |
984 |
|
|
prop (CFAPI_INT, MAP_PROP_WPARTX) |
985 |
|
|
prop (CFAPI_INT, MAP_PROP_WPARTY) |
986 |
|
|
prop (CFAPI_STRING, MAP_PROP_MESSAGE) |
987 |
|
|
prop (CFAPI_PMAP, MAP_PROP_NEXT) |
988 |
|
|
prop (CFAPI_PREGION, MAP_PROP_REGION) |
989 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_OB_ABOVE) |
990 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_OB_BELOW) |
991 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_NEXT_ACTIVE_OB) |
992 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_PREV_ACTIVE_OB) |
993 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_INVENTORY) |
994 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_ENVIRONMENT) |
995 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_HEAD) |
996 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_CONTAINER) |
997 |
|
|
prop (CFAPI_PMAP, OBJECT_PROP_MAP) |
998 |
|
|
prop (CFAPI_INT, OBJECT_PROP_COUNT) |
999 |
|
|
prop (CFAPI_INT, OBJECT_PROP_REFCOUNT) |
1000 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_NAME) |
1001 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_NAME_PLURAL) |
1002 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_TITLE) |
1003 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_RACE) |
1004 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_SLAYING) |
1005 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_SKILL) |
1006 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_MESSAGE) |
1007 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_LORE) |
1008 |
|
|
prop (CFAPI_INT, OBJECT_PROP_X) |
1009 |
|
|
prop (CFAPI_INT, OBJECT_PROP_Y) |
1010 |
|
|
prop (CFAPI_DOUBLE, OBJECT_PROP_SPEED) |
1011 |
|
|
prop (CFAPI_DOUBLE, OBJECT_PROP_SPEED_LEFT) |
1012 |
|
|
prop (CFAPI_INT, OBJECT_PROP_NROF) |
1013 |
|
|
prop (CFAPI_INT, OBJECT_PROP_DIRECTION) |
1014 |
|
|
prop (CFAPI_INT, OBJECT_PROP_FACING) |
1015 |
|
|
prop (CFAPI_INT, OBJECT_PROP_TYPE) |
1016 |
|
|
prop (CFAPI_INT, OBJECT_PROP_SUBTYPE) |
1017 |
|
|
prop (CFAPI_INT, OBJECT_PROP_CLIENT_TYPE) |
1018 |
|
|
prop (CFAPI_INT, OBJECT_PROP_ATTACK_TYPE) |
1019 |
|
|
prop (CFAPI_INT, OBJECT_PROP_PATH_ATTUNED) |
1020 |
|
|
prop (CFAPI_INT, OBJECT_PROP_PATH_REPELLED) |
1021 |
|
|
prop (CFAPI_INT, OBJECT_PROP_PATH_DENIED) |
1022 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MATERIAL) |
1023 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_MATERIAL_NAME) |
1024 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MAGIC) |
1025 |
|
|
prop (CFAPI_INT, OBJECT_PROP_VALUE) |
1026 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LEVEL) |
1027 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LAST_HEAL) |
1028 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LAST_SP) |
1029 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LAST_GRACE) |
1030 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LAST_EAT) |
1031 |
|
|
prop (CFAPI_INT, OBJECT_PROP_INVISIBLE_TIME) |
1032 |
|
|
prop (CFAPI_INT, OBJECT_PROP_PICK_UP) |
1033 |
|
|
prop (CFAPI_INT, OBJECT_PROP_ITEM_POWER) |
1034 |
|
|
prop (CFAPI_INT, OBJECT_PROP_GEN_SP_ARMOUR) |
1035 |
|
|
prop (CFAPI_INT, OBJECT_PROP_WEIGHT) |
1036 |
|
|
prop (CFAPI_INT, OBJECT_PROP_WEIGHT_LIMIT) |
1037 |
|
|
prop (CFAPI_INT, OBJECT_PROP_CARRYING) |
1038 |
|
|
prop (CFAPI_INT, OBJECT_PROP_GLOW_RADIUS) |
1039 |
|
|
prop (CFAPI_LONG, OBJECT_PROP_PERM_EXP) |
1040 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_CURRENT_WEAPON) |
1041 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_ENEMY) |
1042 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_ATTACKED_BY) |
1043 |
|
|
prop (CFAPI_INT, OBJECT_PROP_RUN_AWAY) |
1044 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_CHOSEN_SKILL) |
1045 |
|
|
prop (CFAPI_INT, OBJECT_PROP_HIDDEN) |
1046 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MOVE_STATUS) |
1047 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MOVE_TYPE) |
1048 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_SPELL_ITEM) |
1049 |
|
|
prop (CFAPI_DOUBLE, OBJECT_PROP_EXP_MULTIPLIER) |
1050 |
|
|
prop (CFAPI_PARCH, OBJECT_PROP_ARCHETYPE) |
1051 |
|
|
prop (CFAPI_PARCH, OBJECT_PROP_OTHER_ARCH) |
1052 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_CUSTOM_NAME) |
1053 |
|
|
prop (CFAPI_INT, OBJECT_PROP_ANIM_SPEED) |
1054 |
|
|
prop (CFAPI_INT, OBJECT_PROP_FRIENDLY) |
1055 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_SHORT_NAME) |
1056 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MAGICAL) |
1057 |
|
|
prop (CFAPI_INT, OBJECT_PROP_LUCK) |
1058 |
|
|
prop (CFAPI_LONG, OBJECT_PROP_EXP) |
1059 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_OWNER) |
1060 |
|
|
prop (CFAPI_POBJECT, OBJECT_PROP_PRESENT) |
1061 |
|
|
prop (CFAPI_INT, OBJECT_PROP_CHEATER) |
1062 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MERGEABLE) |
1063 |
|
|
prop (CFAPI_INT, OBJECT_PROP_PICKABLE) |
1064 |
|
|
prop (CFAPI_INT, OBJECT_PROP_STR) |
1065 |
|
|
prop (CFAPI_INT, OBJECT_PROP_DEX) |
1066 |
|
|
prop (CFAPI_INT, OBJECT_PROP_CON) |
1067 |
|
|
prop (CFAPI_INT, OBJECT_PROP_WIS) |
1068 |
|
|
prop (CFAPI_INT, OBJECT_PROP_INT) |
1069 |
|
|
prop (CFAPI_INT, OBJECT_PROP_POW) |
1070 |
|
|
prop (CFAPI_INT, OBJECT_PROP_CHA) |
1071 |
|
|
prop (CFAPI_INT, OBJECT_PROP_WC) |
1072 |
|
|
prop (CFAPI_INT, OBJECT_PROP_AC) |
1073 |
|
|
prop (CFAPI_INT, OBJECT_PROP_HP) |
1074 |
|
|
prop (CFAPI_INT, OBJECT_PROP_SP) |
1075 |
|
|
prop (CFAPI_INT, OBJECT_PROP_GP) |
1076 |
|
|
prop (CFAPI_INT, OBJECT_PROP_FP) |
1077 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MAXHP) |
1078 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MAXSP) |
1079 |
|
|
prop (CFAPI_INT, OBJECT_PROP_MAXGP) |
1080 |
|
|
prop (CFAPI_INT, OBJECT_PROP_DAM) |
1081 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_GOD) |
1082 |
|
|
prop (CFAPI_STRING, OBJECT_PROP_ARCH_NAME) |
1083 |
|
|
prop (CFAPI_INT, OBJECT_PROP_INVISIBLE) |
1084 |
|
|
prop (CFAPI_INT, OBJECT_PROP_FACE) |
1085 |
|
|
}; |
1086 |
|
|
|
1087 |
|
|
HV *prop_type = get_hv ("cf::PROP_TYPE", 1); |
1088 |
|
|
HV *prop_idx = get_hv ("cf::PROP_IDX", 1); |
1089 |
|
|
|
1090 |
|
|
for (cprop = prop_table + sizeof (prop_table) / sizeof (prop_table [0]); cprop-- > prop_table; ) |
1091 |
|
|
{ |
1092 |
|
|
hv_store (prop_type, cprop->name, strlen (cprop->name), newSViv (cprop->dtype), 0); |
1093 |
|
|
hv_store (prop_idx, cprop->name, strlen (cprop->name), newSViv (cprop->idx ), 0); |
1094 |
|
|
} |
1095 |
|
|
} |
1096 |
|
|
|
1097 |
|
|
void |
1098 |
|
|
LOG (int level, char *msg) |
1099 |
root |
1.6 |
PROTOTYPE: $$ |
1100 |
root |
1.1 |
C_ARGS: level, "%s", msg |
1101 |
|
|
|
1102 |
|
|
char * |
1103 |
|
|
cf_get_maps_directory (char *path) |
1104 |
root |
1.6 |
PROTOTYPE: $ |
1105 |
root |
1.2 |
ALIAS: maps_directory = 0 |
1106 |
root |
1.1 |
|
1107 |
root |
1.5 |
char * |
1108 |
|
|
mapdir () |
1109 |
root |
1.6 |
PROTOTYPE: |
1110 |
root |
1.5 |
ALIAS: |
1111 |
|
|
mapdir = 0 |
1112 |
|
|
uniquedir = 1 |
1113 |
|
|
tmpdir = 2 |
1114 |
|
|
confdir = 3 |
1115 |
|
|
localdir = 4 |
1116 |
|
|
playerdir = 5 |
1117 |
|
|
datadir = 6 |
1118 |
|
|
CODE: |
1119 |
|
|
{ |
1120 |
|
|
int unused_type; |
1121 |
|
|
RETVAL = (char *)systemDirectory (&unused_type, ix); |
1122 |
|
|
} |
1123 |
root |
1.6 |
OUTPUT: RETVAL |
1124 |
root |
1.5 |
|
1125 |
root |
1.4 |
int |
1126 |
|
|
cf_find_animation (char *text) |
1127 |
root |
1.6 |
PROTOTYPE: $ |
1128 |
root |
1.4 |
|
1129 |
root |
1.1 |
MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1130 |
|
|
|
1131 |
|
|
SV * |
1132 |
root |
1.4 |
get_property (object *obj, int type, int idx) |
1133 |
root |
1.1 |
CODE: |
1134 |
|
|
RETVAL = newSVcfapi (type, cf_object_get_property (obj, idx)); |
1135 |
root |
1.6 |
OUTPUT: RETVAL |
1136 |
root |
1.1 |
|
1137 |
root |
1.4 |
SV * |
1138 |
|
|
set_property (object *obj, int type, int idx, SV *newval) |
1139 |
|
|
CODE: |
1140 |
|
|
switch (type) |
1141 |
|
|
{ |
1142 |
|
|
case CFAPI_INT: |
1143 |
|
|
cf_object_set_int_property (obj, idx, SvIV (newval)); |
1144 |
|
|
break; |
1145 |
|
|
case CFAPI_LONG: |
1146 |
|
|
cf_object_set_long_property (obj, idx, SvNV (newval)); |
1147 |
|
|
break; |
1148 |
root |
1.10 |
case CFAPI_DOUBLE: |
1149 |
|
|
{ |
1150 |
|
|
int unused_type; |
1151 |
|
|
object_set_property (&unused_type, obj, idx, (double)SvNV (newval)); |
1152 |
|
|
} |
1153 |
|
|
break; |
1154 |
root |
1.4 |
case CFAPI_STRING: |
1155 |
|
|
cf_object_set_string_property (obj, idx, SvPV_nolen (newval)); |
1156 |
|
|
break; |
1157 |
|
|
default: |
1158 |
|
|
croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1159 |
|
|
} |
1160 |
|
|
|
1161 |
root |
1.14 |
void |
1162 |
root |
1.12 |
inv (object *obj) |
1163 |
|
|
PROTOTYPE: $ |
1164 |
|
|
PPCODE: |
1165 |
|
|
{ |
1166 |
|
|
object *o; |
1167 |
|
|
for (o = obj->inv; o; o = o->below) |
1168 |
root |
1.14 |
XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1169 |
root |
1.12 |
} |
1170 |
|
|
|
1171 |
root |
1.1 |
int cf_object_get_resistance (object *op, int rtype) |
1172 |
root |
1.2 |
ALIAS: resistance = 0 |
1173 |
root |
1.1 |
|
1174 |
|
|
int cf_object_get_flag (object *op, int flag) |
1175 |
|
|
ALIAS: flag = 0 |
1176 |
|
|
|
1177 |
|
|
void cf_object_set_flag (object *op, int flag, int value) |
1178 |
|
|
|
1179 |
|
|
void cf_object_move (object *op, object *originator, int dir) |
1180 |
|
|
|
1181 |
root |
1.13 |
void cf_object_apply (object *op, object *author, int flags = 0) |
1182 |
root |
1.1 |
|
1183 |
|
|
void cf_object_apply_below (object *op) |
1184 |
|
|
|
1185 |
|
|
void cf_object_remove (object *op) |
1186 |
|
|
|
1187 |
|
|
void cf_object_free (object *op) |
1188 |
|
|
|
1189 |
|
|
object *cf_object_present_archname_inside (object *op, char *whatstr) |
1190 |
|
|
|
1191 |
|
|
int cf_object_transfer (object *op, int x, int y, int r, object *orig) |
1192 |
|
|
|
1193 |
|
|
int cf_object_change_map (object *op, int x, int y, mapstruct *map) |
1194 |
|
|
|
1195 |
|
|
object *cf_object_clone (object *op, int clonetype) |
1196 |
|
|
|
1197 |
|
|
int cf_object_pay_item (object *op, object *buyer) |
1198 |
|
|
|
1199 |
|
|
int cf_object_pay_amount (object *op, double amount) |
1200 |
|
|
|
1201 |
|
|
int cf_object_cast_spell (object *caster, object *ctoo, int dir, object *sp_, char *flags) |
1202 |
|
|
|
1203 |
|
|
int cf_object_cast_ability (object *caster, object *ctoo, int dir, object *sp_, char *flags) |
1204 |
|
|
|
1205 |
|
|
void cf_object_learn_spell (object *op, object *sp) |
1206 |
|
|
|
1207 |
|
|
void cf_object_forget_spell (object *op, object *sp) |
1208 |
|
|
|
1209 |
|
|
object *cf_object_check_for_spell (object *op, char *spellname) |
1210 |
|
|
|
1211 |
|
|
int cf_object_query_money (object *op) |
1212 |
root |
1.2 |
ALIAS: money = 0 |
1213 |
root |
1.1 |
|
1214 |
|
|
int cf_object_query_cost (object *op, object *who, int flags) |
1215 |
root |
1.2 |
ALIAS: cost = 0 |
1216 |
root |
1.1 |
|
1217 |
|
|
void cf_object_activate_rune (object *op , object *victim) |
1218 |
|
|
|
1219 |
|
|
int cf_object_check_trigger (object *op, object *cause) |
1220 |
|
|
|
1221 |
|
|
int cf_object_out_of_map (object *op, int x, int y) |
1222 |
|
|
|
1223 |
|
|
void cf_object_drop (object *op, object *author) |
1224 |
|
|
|
1225 |
|
|
void cf_object_take (object *op, object *author) |
1226 |
|
|
|
1227 |
|
|
void cf_object_say (object *op, char *msg) |
1228 |
|
|
|
1229 |
|
|
void cf_object_speak (object *op, char *msg) |
1230 |
|
|
|
1231 |
|
|
object *cf_object_insert_object (object *op, object *container) |
1232 |
|
|
|
1233 |
|
|
const char *cf_object_get_msg (object *ob) |
1234 |
root |
1.2 |
ALIAS: msg = 0 |
1235 |
root |
1.1 |
|
1236 |
|
|
object *cf_object_insert_in_ob (object *ob, object *where) |
1237 |
|
|
|
1238 |
|
|
int cf_object_teleport (object *op, mapstruct *map, int x, int y) |
1239 |
|
|
|
1240 |
|
|
void cf_object_update (object *op, int flags) |
1241 |
|
|
|
1242 |
|
|
void cf_object_pickup (object *op, object *what) |
1243 |
|
|
|
1244 |
|
|
char *cf_object_get_key (object *op, char *keyname) |
1245 |
root |
1.2 |
ALIAS: key = 0 |
1246 |
root |
1.1 |
|
1247 |
|
|
void cf_object_set_key (object *op, char *keyname, char *value) |
1248 |
|
|
|
1249 |
|
|
char * |
1250 |
|
|
base_name (object *ob, int plural) |
1251 |
|
|
CODE: |
1252 |
|
|
RETVAL = cf_query_base_name (ob, plural); |
1253 |
root |
1.6 |
OUTPUT: RETVAL |
1254 |
root |
1.1 |
|
1255 |
|
|
MODULE = cf PACKAGE = cf::object PREFIX = cf_object_ |
1256 |
|
|
|
1257 |
root |
1.8 |
object *cf_create_object_by_name (const char *name = 0) |
1258 |
|
|
PROTOTYPE: ;$ |
1259 |
|
|
ALIAS: |
1260 |
|
|
create_object = 0 |
1261 |
|
|
new = 0 |
1262 |
|
|
CODE: |
1263 |
|
|
RETVAL = name ? cf_create_object_by_name (name) : cf_create_object (); |
1264 |
|
|
OUTPUT: |
1265 |
|
|
RETVAL |
1266 |
root |
1.1 |
|
1267 |
|
|
void cf_fix_object (object *pl) |
1268 |
root |
1.8 |
ALIAS: fix = 0 |
1269 |
root |
1.1 |
|
1270 |
|
|
object *cf_insert_ob_in_ob (object *ob, object *where) |
1271 |
|
|
|
1272 |
root |
1.15 |
void rangevector (object *ob, object *other, int flags = 0) |
1273 |
|
|
PROTOTYPE: $$;$ |
1274 |
|
|
ALIAS: |
1275 |
|
|
direction = 1 |
1276 |
|
|
distance = 2 |
1277 |
|
|
CODE: |
1278 |
|
|
{ |
1279 |
|
|
rv_vector rv; |
1280 |
|
|
// get_rangevector uses these if the objects are not on the same map |
1281 |
|
|
// which is not the same as "on_same_map". |
1282 |
|
|
rv.distance_x = 32767; |
1283 |
|
|
rv.distance_y = 32767; |
1284 |
|
|
get_rangevector (ob, other, &rv, flags); |
1285 |
|
|
EXTEND (SP, 5); |
1286 |
|
|
if (!ix || ix == 2) PUSHs (newSVuv (rv.distance)); |
1287 |
|
|
if (!ix) PUSHs (newSViv (rv.distance_x)); |
1288 |
|
|
if (!ix) PUSHs (newSViv (rv.distance_y)); |
1289 |
|
|
if (!ix || ix == 1) PUSHs (newSViv (rv.direction)); |
1290 |
|
|
if (!ix) PUSHs (newSVcfapi (CFAPI_POBJECT, rv.part)); |
1291 |
|
|
} |
1292 |
|
|
|
1293 |
|
|
bool on_same_map_as (object *ob, object *other) |
1294 |
|
|
CODE: |
1295 |
|
|
RETVAL = on_same_map (ob, other); |
1296 |
|
|
OUTPUT: RETVAL |
1297 |
|
|
|
1298 |
root |
1.1 |
|
1299 |
|
|
MODULE = cf PACKAGE = cf::object::player PREFIX = cf_player_ |
1300 |
|
|
|
1301 |
|
|
player *player (object *op) |
1302 |
|
|
CODE: |
1303 |
|
|
RETVAL = cf_player_find (cf_query_name (op)); |
1304 |
root |
1.6 |
OUTPUT: RETVAL |
1305 |
root |
1.1 |
|
1306 |
root |
1.6 |
void cf_player_message (object *obj, char *txt, int flags = NDI_ORANGE | NDI_UNIQUE) |
1307 |
root |
1.1 |
|
1308 |
|
|
object *cf_player_send_inventory (object *op) |
1309 |
|
|
|
1310 |
root |
1.6 |
char *cf_player_get_ip (object *op) |
1311 |
|
|
ALIAS: ip = 0 |
1312 |
|
|
|
1313 |
|
|
object *cf_player_get_marked_item (object *op) |
1314 |
|
|
ALIAS: marked_item = 0 |
1315 |
root |
1.1 |
|
1316 |
root |
1.6 |
void cf_player_set_marked_item (object *op, object *ob) |
1317 |
|
|
|
1318 |
|
|
partylist *cf_player_get_party (object *op) |
1319 |
|
|
ALIAS: party = 0 |
1320 |
|
|
|
1321 |
|
|
void cf_player_set_party (object *op, partylist *party) |
1322 |
root |
1.1 |
|
1323 |
|
|
|
1324 |
root |
1.4 |
MODULE = cf PACKAGE = cf::object::map PREFIX = cf_ |
1325 |
root |
1.1 |
|
1326 |
root |
1.6 |
MODULE = cf PACKAGE = cf::player PREFIX = cf_player_ |
1327 |
root |
1.1 |
|
1328 |
|
|
player *cf_player_find (char *name) |
1329 |
root |
1.6 |
PROTOTYPE: $ |
1330 |
root |
1.1 |
|
1331 |
|
|
void cf_player_move (player *pl, int dir) |
1332 |
|
|
|
1333 |
root |
1.6 |
# nonstandard |
1334 |
|
|
object *ob (player *pl) |
1335 |
|
|
CODE: |
1336 |
|
|
RETVAL = pl->ob; |
1337 |
|
|
OUTPUT: RETVAL |
1338 |
root |
1.1 |
|
1339 |
root |
1.15 |
player *first () |
1340 |
|
|
CODE: |
1341 |
|
|
RETVAL = first_player; |
1342 |
|
|
OUTPUT: RETVAL |
1343 |
|
|
|
1344 |
|
|
player *next (player *pl) |
1345 |
|
|
CODE: |
1346 |
|
|
RETVAL = pl->next; |
1347 |
|
|
OUTPUT: RETVAL |
1348 |
|
|
|
1349 |
|
|
void |
1350 |
|
|
list () |
1351 |
|
|
PPCODE: |
1352 |
|
|
{ |
1353 |
|
|
player *pl; |
1354 |
|
|
for (pl = first_player; pl; pl = pl->next) |
1355 |
|
|
XPUSHs (newSVcfapi (CFAPI_PPLAYER, pl)); |
1356 |
|
|
} |
1357 |
|
|
|
1358 |
root |
1.6 |
|
1359 |
|
|
MODULE = cf PACKAGE = cf::map PREFIX = cf_map_ |
1360 |
root |
1.1 |
|
1361 |
|
|
SV * |
1362 |
|
|
get_property (mapstruct *obj, int type, int idx) |
1363 |
|
|
CODE: |
1364 |
|
|
RETVAL = newSVcfapi (type, cf_map_get_property (obj, idx)); |
1365 |
root |
1.6 |
OUTPUT: RETVAL |
1366 |
root |
1.1 |
|
1367 |
root |
1.4 |
SV * |
1368 |
|
|
set_property (mapstruct *obj, int type, int idx, SV *newval) |
1369 |
|
|
CODE: |
1370 |
|
|
switch (type) |
1371 |
|
|
{ |
1372 |
|
|
case CFAPI_INT: |
1373 |
|
|
cf_map_set_int_property (obj, idx, SvIV (newval)); |
1374 |
|
|
break; |
1375 |
|
|
default: |
1376 |
|
|
croak ("unhandled type '%d' in set_property '%d'", type, idx); |
1377 |
|
|
} |
1378 |
|
|
|
1379 |
root |
1.11 |
mapstruct *new (int width, int height) |
1380 |
|
|
PROTOTYPE: |
1381 |
|
|
CODE: |
1382 |
|
|
{ |
1383 |
|
|
int unused_type; |
1384 |
|
|
RETVAL = map_get_map (&unused_type, 0, width, height); |
1385 |
|
|
} |
1386 |
|
|
OUTPUT: |
1387 |
|
|
RETVAL |
1388 |
|
|
|
1389 |
root |
1.4 |
mapstruct *cf_map_get_map (char *name) |
1390 |
root |
1.6 |
PROTOTYPE: $ |
1391 |
root |
1.4 |
ALIAS: map = 0 |
1392 |
|
|
|
1393 |
|
|
mapstruct *cf_map_get_first () |
1394 |
root |
1.6 |
PROTOTYPE: |
1395 |
root |
1.4 |
ALIAS: first = 0 |
1396 |
|
|
|
1397 |
|
|
object *cf_map_insert_object_there (mapstruct *where, object *op, object *originator, int flags) |
1398 |
|
|
|
1399 |
|
|
object *cf_map_insert_object (mapstruct *where, object* op, int x, int y) |
1400 |
|
|
|
1401 |
|
|
object* cf_map_present_arch_by_name (mapstruct *map, const char* str, int nx, int ny) |
1402 |
|
|
C_ARGS: str, map, nx, ny |
1403 |
|
|
|
1404 |
|
|
#int cf_map_get_flags (mapstruct* map, mapstruct** nmap, I16 x, I16 y, I16 *nx, I16 *ny) |
1405 |
|
|
|
1406 |
root |
1.14 |
void |
1407 |
root |
1.12 |
at (mapstruct *obj, unsigned int x, unsigned int y) |
1408 |
root |
1.11 |
PROTOTYPE: $$$ |
1409 |
|
|
INIT: |
1410 |
root |
1.14 |
if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_EMPTY; |
1411 |
root |
1.11 |
PPCODE: |
1412 |
|
|
{ |
1413 |
|
|
object *o; |
1414 |
|
|
for (o = GET_MAP_OB (obj, x, y); o; o = o->above) |
1415 |
root |
1.14 |
XPUSHs (sv_2mortal (newSVcfapi (CFAPI_POBJECT, o))); |
1416 |
root |
1.11 |
} |
1417 |
|
|
|
1418 |
root |
1.12 |
SV * |
1419 |
|
|
bot_at (mapstruct *obj, unsigned int x, unsigned int y) |
1420 |
root |
1.11 |
PROTOTYPE: $$$ |
1421 |
|
|
ALIAS: |
1422 |
|
|
top_at = 1 |
1423 |
|
|
flags_at = 2 |
1424 |
|
|
light_at = 3 |
1425 |
|
|
move_block_at = 4 |
1426 |
|
|
move_slow_at = 5 |
1427 |
|
|
move_on_at = 6 |
1428 |
|
|
move_off_at = 7 |
1429 |
|
|
INIT: |
1430 |
|
|
if (x >= MAP_WIDTH (obj) || y >= MAP_HEIGHT (obj)) XSRETURN_UNDEF; |
1431 |
|
|
CODE: |
1432 |
|
|
switch (ix) |
1433 |
|
|
{ |
1434 |
|
|
case 0: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_OB (obj, x, y)); break; |
1435 |
|
|
case 1: RETVAL = newSVcfapi (CFAPI_POBJECT, GET_MAP_TOP (obj, x, y)); break; |
1436 |
|
|
case 2: RETVAL = newSVuv ( GET_MAP_FLAGS (obj, x, y)); break; |
1437 |
|
|
case 3: RETVAL = newSViv ( GET_MAP_LIGHT (obj, x, y)); break; |
1438 |
|
|
case 4: RETVAL = newSVuv ( GET_MAP_MOVE_BLOCK (obj, x, y)); break; |
1439 |
|
|
case 5: RETVAL = newSVuv ( GET_MAP_MOVE_SLOW (obj, x, y)); break; |
1440 |
|
|
case 6: RETVAL = newSVuv ( GET_MAP_MOVE_ON (obj, x, y)); break; |
1441 |
|
|
case 7: RETVAL = newSVuv ( GET_MAP_MOVE_OFF (obj, x, y)); break; |
1442 |
|
|
} |
1443 |
|
|
OUTPUT: |
1444 |
|
|
RETVAL |
1445 |
root |
1.4 |
|
1446 |
root |
1.1 |
|
1447 |
|
|
MODULE = cf PACKAGE = cf::arch PREFIX = cf_archetype_ |
1448 |
|
|
|
1449 |
root |
1.12 |
archetype *cf_archetype_get_first() |
1450 |
root |
1.6 |
PROTOTYPE: |
1451 |
root |
1.2 |
ALIAS: first = 0 |
1452 |
root |
1.1 |
|
1453 |
root |
1.2 |
archetype *cf_archetype_get_next (archetype *arch) |
1454 |
|
|
ALIAS: next = 0 |
1455 |
root |
1.1 |
|
1456 |
root |
1.2 |
archetype *cf_archetype_get_head (archetype *arch) |
1457 |
|
|
ALIAS: head = 0 |
1458 |
root |
1.1 |
|
1459 |
|
|
archetype *cf_archetype_get_more (archetype *arch) |
1460 |
root |
1.2 |
ALIAS: more = 0 |
1461 |
root |
1.1 |
|
1462 |
root |
1.2 |
const char *cf_archetype_get_name (archetype *arch) |
1463 |
|
|
ALIAS: name = 0 |
1464 |
root |
1.1 |
|
1465 |
|
|
MODULE = cf PACKAGE = cf::party PREFIX = cf_party_ |
1466 |
|
|
|
1467 |
|
|
partylist *cf_party_get_first () |
1468 |
root |
1.6 |
PROTOTYPE: |
1469 |
root |
1.1 |
ALIAS: first = 0 |
1470 |
|
|
|
1471 |
|
|
partylist *cf_party_get_next (partylist *party) |
1472 |
|
|
ALIAS: next = 0 |
1473 |
|
|
|
1474 |
root |
1.6 |
const char *cf_party_get_name (partylist *party) |
1475 |
|
|
|
1476 |
root |
1.1 |
const char *cf_party_get_password (partylist *party) |
1477 |
|
|
ALIAS: password = 0 |
1478 |
|
|
|
1479 |
|
|
player *cf_party_get_first_player (partylist *party) |
1480 |
|
|
ALIAS: first_player = 0 |
1481 |
|
|
|
1482 |
|
|
player *cf_party_get_next_player (partylist *party, player *op) |
1483 |
|
|
ALIAS: next_player = 0 |
1484 |
|
|
|
1485 |
|
|
|
1486 |
|
|
MODULE = cf PACKAGE = cf::region PREFIX = cf_region_ |
1487 |
|
|
|
1488 |
|
|
region *cf_region_get_first () |
1489 |
root |
1.6 |
PROTOTYPE: |
1490 |
root |
1.1 |
ALIAS: first = 0 |
1491 |
|
|
|
1492 |
|
|
const char *cf_region_get_name (region *reg) |
1493 |
|
|
ALIAS: name = 0 |
1494 |
|
|
|
1495 |
|
|
region *cf_region_get_next (region *reg) |
1496 |
|
|
ALIAS: next = 0 |
1497 |
|
|
|
1498 |
|
|
region *cf_region_get_parent (region *reg) |
1499 |
|
|
ALIAS: parent = 0 |
1500 |
|
|
|
1501 |
|
|
const char *cf_region_get_longname (region *reg) |
1502 |
|
|
ALIAS: longname = 0 |
1503 |
|
|
|
1504 |
|
|
const char *cf_region_get_message (region *reg) |
1505 |
|
|
ALIAS: message = 0 |
1506 |
|
|
|
1507 |
|
|
|