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.167 by root, Tue Feb 13 21:28:11 2007 UTC vs.
Revision 1.168 by root, Thu Feb 15 03:19:02 2007 UTC

2183 if (pl->ob && pl->ob->map == THIS) 2183 if (pl->ob && pl->ob->map == THIS)
2184 PUSHs (sv_2mortal (to_sv (pl->ob))); 2184 PUSHs (sv_2mortal (to_sv (pl->ob)));
2185 } 2185 }
2186 2186
2187void 2187void
2188maptile::set_regiondata (SV *data, SV *plt) 2188maptile::add_underlay (SV *data, int offset, int stride, SV *palette)
2189 CODE: 2189 CODE:
2190{ 2190{
2191 if (!SvROK (plt) || SvTYPE (SvRV (plt)) != SVt_PVAV) 2191 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2192 croak ("maptile::add_underlay: palette must be arrayref");
2193
2194 palette = SvRV (palette);
2195
2196 STRLEN idxlen;
2197 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen);
2198
2199 for (int x = 0; x < THIS->width; ++x)
2200 for (int y = 0; y < THIS->height; ++y)
2201 {
2202 for (object *op = THIS->at (x, y).bot; op; op = op->above)
2203 if (op->flag [FLAG_IS_FLOOR])
2204 goto skip_space;
2205
2206 {
2207 int offs = offset + y * stride + x;
2208 if (IN_RANGE_EXC (offs, 0, idxlen))
2209 {
2210 if (SV **elem = av_fetch ((AV *)palette, idx [offs], 0))
2211 {
2212 object *ob = get_archetype (SvPVutf8_nolen (*elem));
2213 ob->flag [FLAG_NO_MAP_SAVE] = true;
2214 THIS->insert (ob, x, y, 0, INS_ABOVE_FLOOR_ONLY);
2215 }
2216 }
2217 }
2218
2219 skip_space: ;
2220 }
2221}
2222
2223void
2224maptile::set_regiondata (SV *data, int offset, int stride, SV *palette)
2225 CODE:
2226{
2227 if (!SvROK (palette) || SvTYPE (SvRV (palette)) != SVt_PVAV)
2192 croak ("maptile::set_regiondata needs arrayref as plt arg"); 2228 croak ("maptile::set_regiondata: palette must be arrayref");
2193 2229
2194 AV *av = (AV *)SvRV (plt); 2230 palette = SvRV (palette);
2195 2231
2196 region **regionmap = (region **)malloc ((av_len (av) + 1) * sizeof (region *)); 2232 STRLEN idxlen;
2233 const uint8_t *idx = (const uint8_t *)SvPVbyte (data, idxlen);
2197 2234
2235 region **regionmap = (region **)malloc (
2236 (av_len ((AV *)palette) + 1) * sizeof (region *));
2237 uint8_t *regions = salloc<uint8_t> (THIS->size ());
2238
2198 for (int i = av_len (av) + 1; i--; ) 2239 for (int i = av_len ((AV *)palette) + 1; i--; )
2199 regionmap [i] = region::find (SvPVutf8_nolen (*av_fetch (av, i, 1))); 2240 regionmap [i] = region::find (
2241 SvPVutf8_nolen (*av_fetch ((AV *)palette, i, 1)));
2200 2242
2201 THIS->regions = salloc<uint8_t> (THIS->size (), (uint8_t *)SvPVbyte_nolen (data)); 2243 for (int y = 0; y < THIS->height; ++y)
2244 memcpy (regions + y * THIS->width, idx + offset + y * stride, THIS->width);
2245
2246 sfree (THIS->regions, THIS->size ());
2247 free (THIS->regionmap);
2248
2249 THIS->regions = regions;
2202 THIS->regionmap = regionmap; 2250 THIS->regionmap = regionmap;
2203} 2251}
2204 2252
2205void play_sound_map (maptile *map, int x, int y, int sound_num) 2253void play_sound_map (maptile *map, int x, int y, int sound_num)
2206 2254

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines