--- deliantra/Deliantra-Client/Client.xs 2007/08/01 12:43:31 1.217 +++ deliantra/Deliantra-Client/Client.xs 2007/08/10 04:02:13 1.221 @@ -1352,6 +1352,9 @@ float t = SvNV (*hv_fetch (hv, "t", 1, 1)); int name = SvIV (*hv_fetch (hv, "name", 4, 1)); + if (name <= 0) + XSRETURN_EMPTY; + if (items < 5) { w = SvNV (*hv_fetch (hv, "w", 1, 1)); @@ -1549,14 +1552,16 @@ } } -void +SV * map1a_update (CFPlus::Map self, SV *data_, int extmap) CODE: { uint8_t *data = (uint8_t *)SvPVbyte_nolen (data_); uint8_t *data_end = (uint8_t *)SvEND (data_); mapcell *cell; - int x, y, flags; + int x, y, z, flags; + AV *missing = newAV (); + RETVAL = newRV_noinc ((SV *)missing); while (data < data_end - 1) { @@ -1617,31 +1622,34 @@ cell->darkness = *data++ + 1; } - if (flags & 4) - { - faceid face = (data [0] << 8) + data [1]; data += 2; - need_facenum (self, face); - cell->tile [0] = self->face2tile [face]; - } + for (z = 0; z <= 2; ++z) + if (flags & (4 >> z)) + { + faceid face = (data [0] << 8) + data [1]; data += 2; + need_facenum (self, face); + cell->tile [z] = self->face2tile [face]; - if (flags & 2) - { - faceid face = (data [0] << 8) + data [1]; data += 2; - need_facenum (self, face); - cell->tile [1] = self->face2tile [face]; - } + if (cell->tile [z]) + { + maptex *tex = self->tex + cell->tile [z]; + if (!tex->name) + av_push (missing, newSViv (cell->tile [z])); - if (flags & 1) - { - faceid face = (data [0] << 8) + data [1]; data += 2; - need_facenum (self, face); - cell->tile [2] = self->face2tile [face]; - } + if (tex->smoothtile) + { + maptex *smooth = self->tex + tex->smoothtile; + if (!smooth->name) + av_push (missing, newSViv (tex->smoothtile)); + } + } + } } else cell->darkness = 0; } } + OUTPUT: + RETVAL SV * mapmap (CFPlus::Map self, int x0, int y0, int w, int h) @@ -1725,7 +1733,7 @@ glBegin (GL_QUADS); - last_name = 0; + last_name = -1; mx += self->x; my += self->y; @@ -1770,8 +1778,7 @@ if (tile) { maptex tex = self->tex [tile]; - int px = (x + 1) * T - tex.w; - int py = (y + 1) * T - tex.h; + int px, py; // suppressing texture state switches here // is only moderately effective, but worth the extra effort @@ -1785,6 +1792,9 @@ glBegin (GL_QUADS); } + px = (x + 1) * T - tex.w; + py = (y + 1) * T - tex.h; + glTexCoord2f (0 , 0 ); glVertex2f (px , py ); glTexCoord2f (0 , tex.t); glVertex2f (px , py + tex.h); glTexCoord2f (tex.s, tex.t); glVertex2f (px + tex.w, py + tex.h); @@ -2262,10 +2272,12 @@ OUTPUT: RETVAL -void -close (CFPlus::RW self) - CODE: - SDL_RWclose (self); +# fails on win32: +# CFPlus.xs(2268) : error C2059: syntax error : '(' +#void +#close (CFPlus::RW self) +# CODE: +# (self->(close)) (self); MODULE = CFPlus PACKAGE = CFPlus::Channel @@ -2335,7 +2347,15 @@ void set_position (CFPlus::Channel self, int angle, int distance) CODE: + +void +set_position_r (CFPlus::Channel self, int dx, int dy, int maxdistance) + CODE: +{ + int distance = sqrtf (dx * dx + dy * dy) * (255.f / sqrtf (maxdistance * maxdistance)); + int angle = 360 + (int)roundf (atan2f (dx, -dy) * 180.f / (float)M_PI); Mix_SetPosition (self, angle, CLAMP (distance, 0, 255)); +} void set_reverse_stereo (CFPlus::Channel self, int flip)