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.344 by root, Sat Jan 16 00:08:33 2010 UTC vs.
Revision 1.345 by root, Sat Jan 16 13:41:37 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
28 28
29#include <cstdarg> 29#include <cstdarg>
30#include <typeinfo> 30#include <typeinfo>
31 31
32#include "global.h" 32#include "global.h"
33#include "loader.h"
34#include "../random_maps/random_map.h" 33#include "../random_maps/random_map.h"
35#include "evthread.h" 34#include "evthread.h"
36#include "sproto.h" 35#include "sproto.h"
37 36
38#include <unistd.h> 37#include <unistd.h>
96 *cv_cf_client_send_msg, 95 *cv_cf_client_send_msg,
97 *cv_cf_tick, 96 *cv_cf_tick,
98 *cv_cf_match_match; 97 *cv_cf_match_match;
99 98
100#ifndef newSVpv_utf8 99#ifndef newSVpv_utf8
101static inline SV * 100static SV *
102newSVpv_utf8 (const char *s) 101newSVpv_utf8 (const char *s)
103{ 102{
104 if (!s) 103 if (!s)
105 return newSV (0); 104 return newSV (0);
106 105
109 return sv; 108 return sv;
110} 109}
111#endif 110#endif
112 111
113#ifndef newSVpvn_utf8 112#ifndef newSVpvn_utf8
114static inline SV * 113static SV *
115newSVpvn_utf8 (const char *s, STRLEN l, int utf8) 114newSVpvn_utf8 (const char *s, STRLEN l, int utf8)
116{ 115{
117 if (!s) 116 if (!s)
118 return newSV (0); 117 return newSV (0);
119 118
123 SvUTF8_on (sv); 122 SvUTF8_on (sv);
124 123
125 return sv; 124 return sv;
126} 125}
127#endif 126#endif
127
128static noinline utf8_string
129cfSvPVutf8_nolen (SV *sv)
130{
131 SvGETMAGIC (sv);
132
133 if (SvPOK (sv))
134 {
135 if (!SvUTF8 (sv))
136 sv_utf8_upgrade_nomg (sv);
137
138 return SvPVX (sv);
139 }
140
141 return SvPV_nolen (sv);
142}
128 143
129// helper cast function, returns super class * or 0 144// helper cast function, returns super class * or 0
130template<class super> 145template<class super>
131static super * 146static super *
132is_a (attachable *at) 147is_a (attachable *at)
528 SV *sv = to_sv (static_cast<dynbuf *> (v)); 543 SV *sv = to_sv (static_cast<dynbuf *> (v));
529 SvUTF8_on (sv); 544 SvUTF8_on (sv);
530 return sv; 545 return sv;
531} 546}
532 547
533static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } 548static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? cfSvPVutf8_nolen (sv) : 0; }
534static inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } 549static inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; }
535static inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } 550static inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); }
536static inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } 551static inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); }
537static inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); } 552static inline void sv_to (SV *sv, unsigned char &v) { v = SvIV (sv); }
538static inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); } 553static inline void sv_to (SV *sv, signed short &v) { v = SvIV (sv); }
1233 1248
1234 return retval; 1249 return retval;
1235} 1250}
1236 1251
1237void 1252void
1238log_backtrace (const char *msg) 1253log_backtrace (const_utf8_string msg)
1239{ 1254{
1240#if HAVE_BACKTRACE 1255#if HAVE_BACKTRACE
1241 void *addr [20]; 1256 void *addr [20];
1242 int size = backtrace (addr, 20); 1257 int size = backtrace (addr, 20);
1243 1258
2555 2570
2556 if (IN_RANGE_EXC (offs, 0, idxlen)) 2571 if (IN_RANGE_EXC (offs, 0, idxlen))
2557 { 2572 {
2558 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) 2573 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2559 { 2574 {
2560 object *ob = get_archetype (SvPVutf8_nolen (*elem)); 2575 object *ob = get_archetype (cfSvPVutf8_nolen (*elem));
2561 ob->flag [FLAG_NO_MAP_SAVE] = true; 2576 ob->flag [FLAG_NO_MAP_SAVE] = true;
2562 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); 2577 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2563 2578
2564 if (ob->randomitems && !ob->above) 2579 if (ob->randomitems && !ob->above)
2565 { 2580 {
2596 2611
2597 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1]; 2612 region_ptr *regionmap = new region_ptr [av_len ((AV *)palette) + 1];
2598 uint8_t *regions = salloc<uint8_t> (THIS->size ()); 2613 uint8_t *regions = salloc<uint8_t> (THIS->size ());
2599 2614
2600 for (int i = av_len ((AV *)palette) + 1; i--; ) 2615 for (int i = av_len ((AV *)palette) + 1; i--; )
2601 regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); 2616 regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1)));
2602 2617
2603 for (int y = 0; y < THIS->height; ++y) 2618 for (int y = 0; y < THIS->height; ++y)
2604 memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); 2619 memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width);
2605 2620
2606 sfree (THIS->regions, THIS->size ()); 2621 sfree (THIS->regions, THIS->size ());
3086 } 3101 }
3087 else 3102 else
3088 anim = &animation::create (name, av_len (av) + 1, facings); 3103 anim = &animation::create (name, av_len (av) + 1, facings);
3089 3104
3090 for (int i = 0; i < anim->num_animations; ++i) 3105 for (int i = 0; i < anim->num_animations; ++i)
3091 anim->faces [i] = face_find (SvPVutf8_nolen (*av_fetch (av, i, 1))); 3106 anim->faces [i] = face_find (cfSvPVutf8_nolen (*av_fetch (av, i, 1)));
3092} 3107}
3093 OUTPUT: RETVAL 3108 OUTPUT: RETVAL
3094 3109
3095void invalidate_all () 3110void invalidate_all ()
3096 CODE: 3111 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines