… | |
… | |
4 | |
4 | |
5 | /* |
5 | /* |
6 | * This code is placed under the GNU General Public Licence (GPL) |
6 | * This code is placed under the GNU General Public Licence (GPL) |
7 | * |
7 | * |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
8 | * Copyright (C) 2001-2005 by Chachkoff Yann |
9 | * Copyright (C) 2006 by Marc Lehmann <cf@schmorpd.e> |
9 | * Copyright (C) 2006 by Marc Lehmann <cf@schmorp.de> |
10 | * |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
171 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
171 | inline SV *to_sv (unsigned short v) { return newSVuv (v); } |
172 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
172 | inline SV *to_sv ( signed int v) { return newSViv (v); } |
173 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
173 | inline SV *to_sv (unsigned int v) { return newSVuv (v); } |
174 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
174 | inline SV *to_sv ( signed long v) { return newSViv (v); } |
175 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
175 | inline SV *to_sv (unsigned long v) { return newSVuv (v); } |
|
|
176 | inline SV *to_sv ( signed long long v) { return newSVval64 (v); } |
|
|
177 | inline SV *to_sv (unsigned long long v) { return newSVval64 (v); } |
176 | inline SV *to_sv (float v) { return newSVnv (v); } |
178 | inline SV *to_sv (float v) { return newSVnv (v); } |
177 | inline SV *to_sv (double v) { return newSVnv (v); } |
179 | inline SV *to_sv (double v) { return newSVnv (v); } |
178 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
180 | inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } |
179 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
181 | inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } |
180 | inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); } |
182 | inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); } |
181 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::archetype::wrap"); } |
183 | inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); } |
182 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
184 | inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } |
183 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
185 | inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } |
184 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
186 | inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } |
185 | |
187 | |
186 | inline SV *to_sv (object & v) { return to_sv (&v); } |
188 | inline SV *to_sv (object & v) { return to_sv (&v); } |
… | |
… | |
199 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
201 | inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } |
200 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
202 | inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } |
201 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
203 | inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } |
202 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
204 | inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } |
203 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
205 | inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } |
|
|
206 | inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); } |
|
|
207 | inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); } |
204 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
208 | inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } |
205 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
209 | inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } |
206 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
210 | inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } |
207 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
211 | inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } |
208 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::archetype"); } |
212 | inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); } |
209 | inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); } |
213 | inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); } |
210 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
214 | inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } |
211 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
215 | inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } |
212 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
216 | inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } |
213 | |
217 | |
214 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
218 | inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO |
215 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
219 | inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO |
216 | |
220 | |
|
|
221 | template<class T> |
|
|
222 | inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; } |
|
|
223 | |
217 | template<int N> |
224 | template<int N> |
218 | inline void sv_to (SV *sv, char (&v)[N]) { snprintf (v, N, "%s", SvPV_nolen (sv)); } |
225 | inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); } |
219 | |
226 | |
220 | static SV * |
227 | static SV * |
221 | newSVdt_va (va_list &ap, data_type type) |
228 | newSVdt_va (va_list &ap, data_type type) |
222 | { |
229 | { |
223 | SV *sv; |
230 | SV *sv; |
… | |
… | |
1254 | const_iv (AT_BLIND) |
1261 | const_iv (AT_BLIND) |
1255 | const_iv (AT_INTERNAL) |
1262 | const_iv (AT_INTERNAL) |
1256 | const_iv (AT_LIFE_STEALING) |
1263 | const_iv (AT_LIFE_STEALING) |
1257 | const_iv (AT_DISEASE) |
1264 | const_iv (AT_DISEASE) |
1258 | |
1265 | |
1259 | const_iv (QUEST_IN_PROGRESS) |
|
|
1260 | const_iv (QUEST_DONE_QUEST) |
|
|
1261 | const_iv (QUEST_DONE_TASK) |
|
|
1262 | const_iv (QUEST_START_QUEST) |
|
|
1263 | const_iv (QUEST_END_QUEST) |
|
|
1264 | const_iv (QUEST_START_TASK) |
|
|
1265 | const_iv (QUEST_END_TASK) |
|
|
1266 | const_iv (QUEST_OVERRIDE) |
|
|
1267 | const_iv (QUEST_ON_ACTIVATE) |
|
|
1268 | |
|
|
1269 | const_iv (WEAP_HIT) |
1266 | const_iv (WEAP_HIT) |
1270 | const_iv (WEAP_SLASH) |
1267 | const_iv (WEAP_SLASH) |
1271 | const_iv (WEAP_PIERCE) |
1268 | const_iv (WEAP_PIERCE) |
1272 | const_iv (WEAP_CLEAVE) |
1269 | const_iv (WEAP_CLEAVE) |
1273 | const_iv (WEAP_SLICE) |
1270 | const_iv (WEAP_SLICE) |
… | |
… | |
1601 | } |
1598 | } |
1602 | |
1599 | |
1603 | //I_EVENT_API (PACKAGE); |
1600 | //I_EVENT_API (PACKAGE); |
1604 | } |
1601 | } |
1605 | |
1602 | |
1606 | void _reload_1 () |
1603 | void _init_vars () |
1607 | CODE: |
1604 | CODE: |
1608 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1605 | cb_global = get_av ("cf::CB_GLOBAL", 1); |
1609 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1606 | cb_object = get_av ("cf::CB_OBJECT", 1); |
1610 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1607 | cb_player = get_av ("cf::CB_PLAYER", 1); |
1611 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1608 | cb_type = get_av ("cf::CB_TYPE" , 1); |
1612 | cb_map = get_av ("cf::CB_MAP" , 1); |
1609 | cb_map = get_av ("cf::CB_MAP" , 1); |
1613 | |
1610 | |
1614 | void _reload_2 () |
1611 | void _global_reattach () |
1615 | CODE: |
1612 | CODE: |
1616 | { |
1613 | { |
1617 | // reattach to all attachable objects in the game. |
1614 | // reattach to all attachable objects in the game. |
1618 | for (player *pl = first_player; pl; pl = pl->next) |
1615 | for (player *pl = first_player; pl; pl = pl->next) |
1619 | reattach (pl); |
1616 | reattach (pl); |
… | |
… | |
1768 | if (items >= 3) |
1765 | if (items >= 3) |
1769 | if (value) |
1766 | if (value) |
1770 | SET_FLAG (op, flag); |
1767 | SET_FLAG (op, flag); |
1771 | else |
1768 | else |
1772 | CLEAR_FLAG (op, flag); |
1769 | CLEAR_FLAG (op, flag); |
|
|
1770 | OUTPUT: RETVAL |
|
|
1771 | |
|
|
1772 | object *head (object *op) |
|
|
1773 | PROTOTYPE: $ |
|
|
1774 | CODE: |
|
|
1775 | RETVAL = op->head ? op->head : op; |
|
|
1776 | OUTPUT: RETVAL |
|
|
1777 | |
|
|
1778 | int is_head (object *op) |
|
|
1779 | PROTOTYPE: $ |
|
|
1780 | CODE: |
|
|
1781 | RETVAL = !op->head; |
1773 | OUTPUT: RETVAL |
1782 | OUTPUT: RETVAL |
1774 | |
1783 | |
1775 | void |
1784 | void |
1776 | inv (object *obj) |
1785 | inv (object *obj) |
1777 | PROTOTYPE: $ |
1786 | PROTOTYPE: $ |