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.46 by root, Fri Sep 8 17:34:02 2006 UTC vs.
Revision 1.55 by root, Tue Sep 12 18:15:34 2006 UTC

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.
171inline SV *to_sv (unsigned short v) { return newSVuv (v); } 171inline SV *to_sv (unsigned short v) { return newSVuv (v); }
172inline SV *to_sv ( signed int v) { return newSViv (v); } 172inline SV *to_sv ( signed int v) { return newSViv (v); }
173inline SV *to_sv (unsigned int v) { return newSVuv (v); } 173inline SV *to_sv (unsigned int v) { return newSVuv (v); }
174inline SV *to_sv ( signed long v) { return newSViv (v); } 174inline SV *to_sv ( signed long v) { return newSViv (v); }
175inline SV *to_sv (unsigned long v) { return newSVuv (v); } 175inline SV *to_sv (unsigned long v) { return newSVuv (v); }
176inline SV *to_sv ( signed long long v) { return newSVval64 (v); }
177inline SV *to_sv (unsigned long long v) { return newSVval64 (v); }
176inline SV *to_sv (float v) { return newSVnv (v); } 178inline SV *to_sv (float v) { return newSVnv (v); }
177inline SV *to_sv (double v) { return newSVnv (v); } 179inline SV *to_sv (double v) { return newSVnv (v); }
178inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); } 180inline SV *to_sv (player * v) { return newSVattachable (v, "cf::player::wrap"); }
179inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); } 181inline SV *to_sv (object * v) { return newSVattachable (v, v && v->type == PLAYER ? "cf::object::player::wrap" : "cf::object::wrap"); }
180inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); } 182inline SV *to_sv (mapstruct * v) { return newSVattachable (v, "cf::map::wrap"); }
181inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::archetype::wrap"); } 183inline SV *to_sv (archetype * v) { return newSVptr (v, "cf::arch::wrap"); }
182inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); } 184inline SV *to_sv (partylist * v) { return newSVptr (v, "cf::party::wrap"); }
183inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); } 185inline SV *to_sv (region * v) { return newSVptr (v, "cf::region::wrap"); }
184inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); } 186inline SV *to_sv (living * v) { return newSVptr (v, "cf::living::wrap"); }
185 187
186inline SV *to_sv (object & v) { return to_sv (&v); } 188inline SV *to_sv (object & v) { return to_sv (&v); }
199inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); } 201inline void sv_to (SV *sv, unsigned short &v) { v = SvIV (sv); }
200inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); } 202inline void sv_to (SV *sv, signed int &v) { v = SvIV (sv); }
201inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); } 203inline void sv_to (SV *sv, unsigned int &v) { v = SvUV (sv); }
202inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); } 204inline void sv_to (SV *sv, signed long &v) { v = SvIV (sv); }
203inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); } 205inline void sv_to (SV *sv, unsigned long &v) { v = SvUV (sv); }
206inline void sv_to (SV *sv, signed long long &v) { v = ( signed long long)SvVAL64 (sv); }
207inline void sv_to (SV *sv, unsigned long long &v) { v = (unsigned long long)SvVAL64 (sv); }
204inline void sv_to (SV *sv, float &v) { v = SvNV (sv); } 208inline void sv_to (SV *sv, float &v) { v = SvNV (sv); }
205inline void sv_to (SV *sv, double &v) { v = SvNV (sv); } 209inline void sv_to (SV *sv, double &v) { v = SvNV (sv); }
206inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); } 210inline void sv_to (SV *sv, player * &v) { v = (player *)SvPTR_ornull (sv, "cf::player"); }
207inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); } 211inline void sv_to (SV *sv, object * &v) { v = (object *)SvPTR_ornull (sv, "cf::object"); }
208inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::archetype"); } 212inline void sv_to (SV *sv, archetype * &v) { v = (archetype *)SvPTR_ornull (sv, "cf::arch"); }
209inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); } 213inline void sv_to (SV *sv, mapstruct * &v) { v = (mapstruct *)SvPTR_ornull (sv, "cf::map"); }
210inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); } 214inline void sv_to (SV *sv, partylist * &v) { v = (partylist *)SvPTR_ornull (sv, "cf::party"); }
211inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); } 215inline void sv_to (SV *sv, region * &v) { v = (region *)SvPTR_ornull (sv, "cf::region"); }
212inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); } 216inline void sv_to (SV *sv, living * &v) { v = (living *)SvPTR_ornull (sv, "cf::living"); }
213 217
214inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO 218inline void sv_to (SV *sv, New_Face * &v) { v = &new_faces[FindFace (SvPV_nolen (sv), 0)]; } //TODO
215inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO 219inline void sv_to (SV *sv, treasurelist * &v) { v = find_treasurelist (SvPV_nolen (sv)); } // TODO
216 220
221template<class T>
222inline void sv_to (SV *sv, refptr<T> &v) { T *tmp; sv_to (sv, tmp); v = tmp; }
223
217template<int N> 224template<int N>
218inline void sv_to (SV *sv, char (&v)[N]) { snprintf (v, N, "%s", SvPV_nolen (sv)); } 225inline void sv_to (SV *sv, char (&v)[N]) { assign (v, SvPV_nolen (sv)); }
219 226
220static SV * 227static SV *
221newSVdt_va (va_list &ap, data_type type) 228newSVdt_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
1606void _reload_1 () 1603void _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
1614void _reload_2 () 1611void _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
1772object *head (object *op)
1773 PROTOTYPE: $
1774 CODE:
1775 RETVAL = op->head ? op->head : op;
1776 OUTPUT: RETVAL
1777
1778int is_head (object *op)
1779 PROTOTYPE: $
1780 CODE:
1781 RETVAL = !op->head;
1773 OUTPUT: RETVAL 1782 OUTPUT: RETVAL
1774 1783
1775void 1784void
1776inv (object *obj) 1785inv (object *obj)
1777 PROTOTYPE: $ 1786 PROTOTYPE: $

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines