… | |
… | |
19 | * GNU General Public License for more details. |
19 | * GNU General Public License for more details. |
20 | * |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
23 | * Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | */ |
24 | */ |
25 | |
25 | |
26 | #define PLUGIN_NAME "perl" |
26 | #define PLUGIN_NAME "perl" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
27 | #define PLUGIN_VERSION "cfperl 0.5" |
28 | |
28 | |
29 | #include <plugin_common.h> |
29 | #include <plugin_common.h> |
… | |
… | |
192 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
192 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
193 | |
193 | |
194 | template<int N> |
194 | template<int N> |
195 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
195 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
196 | |
196 | |
|
|
197 | inline void sv_to (SV *sv, rangetype &v) { v = (rangetype) SvIV (sv); } |
|
|
198 | inline void sv_to (SV *sv, bowtype_t &v) { v = (bowtype_t) SvIV (sv); } |
|
|
199 | inline void sv_to (SV *sv, petmode_t &v) { v = (petmode_t) SvIV (sv); } |
|
|
200 | inline void sv_to (SV *sv, usekeytype &v) { v = (usekeytype) SvIV (sv); } |
|
|
201 | inline void sv_to (SV *sv, unapplymode &v) { v = (unapplymode) SvIV (sv); } |
|
|
202 | |
197 | inline void sv_to (SV *sv, UUID &v) |
203 | inline void sv_to (SV *sv, UUID &v) |
198 | { |
204 | { |
199 | unsigned int version; |
205 | unsigned int version; |
200 | |
206 | |
201 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
207 | if (2 != sscanf (SvPV_nolen (sv), "<%d.%" SCNx64 ">", &version, &v.seq) || 1 != version) |
202 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
208 | croak ("unparsable uuid: %s", SvPV_nolen (sv)); |
203 | } |
209 | } |
|
|
210 | |
|
|
211 | inline void sv_to (SV *sv, object::flags_t::reference v) { v = boolSV (sv); } |
204 | |
212 | |
205 | static SV * |
213 | static SV * |
206 | newSVdt_va (va_list &ap, data_type type) |
214 | newSVdt_va (va_list &ap, data_type type) |
207 | { |
215 | { |
208 | SV *sv; |
216 | SV *sv; |
… | |
… | |
1410 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1418 | const_iv (FLAG_ACTIVATE_ON_RELEASE) |
1411 | const_iv (FLAG_IS_WATER) |
1419 | const_iv (FLAG_IS_WATER) |
1412 | const_iv (FLAG_CONTENT_ON_GEN) |
1420 | const_iv (FLAG_CONTENT_ON_GEN) |
1413 | const_iv (FLAG_IS_A_TEMPLATE) |
1421 | const_iv (FLAG_IS_A_TEMPLATE) |
1414 | const_iv (FLAG_IS_BUILDABLE) |
1422 | const_iv (FLAG_IS_BUILDABLE) |
1415 | const_iv (FLAG_AFK) |
|
|
1416 | |
1423 | |
1417 | const_iv (NDI_BLACK) |
1424 | const_iv (NDI_BLACK) |
1418 | const_iv (NDI_WHITE) |
1425 | const_iv (NDI_WHITE) |
1419 | const_iv (NDI_NAVY) |
1426 | const_iv (NDI_NAVY) |
1420 | const_iv (NDI_RED) |
1427 | const_iv (NDI_RED) |
… | |
… | |
1836 | RETVAL = object::first; |
1843 | RETVAL = object::first; |
1837 | OUTPUT: RETVAL |
1844 | OUTPUT: RETVAL |
1838 | |
1845 | |
1839 | # missing properties |
1846 | # missing properties |
1840 | |
1847 | |
1841 | int flag (object *op, int flag, int value = 1) |
|
|
1842 | PROTOTYPE: $$;$ |
|
|
1843 | CODE: |
|
|
1844 | RETVAL = op->flag [flag]; |
|
|
1845 | if (items >= 3) |
|
|
1846 | op->flag [flag] = value; |
|
|
1847 | OUTPUT: RETVAL |
|
|
1848 | |
|
|
1849 | object *head (object *op) |
1848 | object *head (object *op) |
1850 | PROTOTYPE: $ |
1849 | PROTOTYPE: $ |
1851 | CODE: |
1850 | CODE: |
1852 | RETVAL = op->head ? op->head : op; |
1851 | RETVAL = op->head ? op->head : op; |
1853 | OUTPUT: RETVAL |
1852 | OUTPUT: RETVAL |
… | |
… | |
1889 | object::remove_statbonus () |
1888 | object::remove_statbonus () |
1890 | |
1889 | |
1891 | object *find_best_object_match (object *op, const char *match) |
1890 | object *find_best_object_match (object *op, const char *match) |
1892 | |
1891 | |
1893 | object *find_marked_object (object *op) |
1892 | object *find_marked_object (object *op) |
1894 | |
|
|
1895 | int resistance (object *op, int rtype, int newval = 0) |
|
|
1896 | CODE: |
|
|
1897 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1898 | croak ("resistance out of bounds"); |
|
|
1899 | RETVAL = op->resist [rtype]; |
|
|
1900 | if (items >= 3) |
|
|
1901 | op->resist [rtype] = newval; |
|
|
1902 | OUTPUT: RETVAL |
|
|
1903 | |
|
|
1904 | void set_resistance (object *op, int rtype, int val) |
|
|
1905 | CODE: |
|
|
1906 | if (rtype < 0 || rtype >= NROFATTACKS) |
|
|
1907 | op->resist[rtype] = val; |
|
|
1908 | |
1893 | |
1909 | int need_identify (const object *obj); |
1894 | int need_identify (const object *obj); |
1910 | |
1895 | |
1911 | int apply_shop_mat (object *shop_mat, object *op); |
1896 | int apply_shop_mat (object *shop_mat, object *op); |
1912 | |
1897 | |