--- deliantra/server/server/cfperl.xs 2010/01/16 00:08:33 1.344 +++ deliantra/server/server/cfperl.xs 2010/01/16 13:41:37 1.345 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the @@ -30,7 +30,6 @@ #include #include "global.h" -#include "loader.h" #include "../random_maps/random_map.h" #include "evthread.h" #include "sproto.h" @@ -98,7 +97,7 @@ *cv_cf_match_match; #ifndef newSVpv_utf8 -static inline SV * +static SV * newSVpv_utf8 (const char *s) { if (!s) @@ -111,7 +110,7 @@ #endif #ifndef newSVpvn_utf8 -static inline SV * +static SV * newSVpvn_utf8 (const char *s, STRLEN l, int utf8) { if (!s) @@ -126,6 +125,22 @@ } #endif +static noinline utf8_string +cfSvPVutf8_nolen (SV *sv) +{ + SvGETMAGIC (sv); + + if (SvPOK (sv)) + { + if (!SvUTF8 (sv)) + sv_utf8_upgrade_nomg (sv); + + return SvPVX (sv); + } + + return SvPV_nolen (sv); +} + // helper cast function, returns super class * or 0 template static super * @@ -530,7 +545,7 @@ return sv; } -static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? SvPVutf8_nolen (sv) : 0; } +static inline void sv_to (SV *sv, shstr &v) { v = SvOK (sv) ? cfSvPVutf8_nolen (sv) : 0; } static inline void sv_to (SV *sv, char * &v) { free (v); v = SvOK (sv) ? strdup (SvPV_nolen (sv)) : 0; } static inline void sv_to (SV *sv, bool &v) { v = SvIV (sv); } static inline void sv_to (SV *sv, signed char &v) { v = SvIV (sv); } @@ -1235,7 +1250,7 @@ } void -log_backtrace (const char *msg) +log_backtrace (const_utf8_string msg) { #if HAVE_BACKTRACE void *addr [20]; @@ -2557,7 +2572,7 @@ { if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0)) { - object *ob = get_archetype (SvPVutf8_nolen (*elem)); + object *ob = get_archetype (cfSvPVutf8_nolen (*elem)); ob->flag [FLAG_NO_MAP_SAVE] = true; THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY); @@ -2598,7 +2613,7 @@ uint8_t *regions = salloc (THIS->size ()); for (int i = av_len ((AV *)palette) + 1; i--; ) - regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); + regionmap [i] = region::find (cfSvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1))); for (int y = 0; y < THIS->height; ++y) memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width); @@ -3088,7 +3103,7 @@ anim = &animation::create (name, av_len (av) + 1, facings); for (int i = 0; i < anim->num_animations; ++i) - anim->faces [i] = face_find (SvPVutf8_nolen (*av_fetch (av, i, 1))); + anim->faces [i] = face_find (cfSvPVutf8_nolen (*av_fetch (av, i, 1))); } OUTPUT: RETVAL