--- deliantra/Deliantra-Client/Client.xs 2007/04/11 04:32:51 1.179 +++ deliantra/Deliantra-Client/Client.xs 2007/04/21 23:36:20 1.187 @@ -347,7 +347,7 @@ static void smooth_or_bits (HV *hv, smooth_key *key, IV bits) { - SV **sv = hv_fetch (hv, (char *)key, sizeof (key), 1); + SV **sv = hv_fetch (hv, (char *)key, sizeof (*key), 1); if (SvIOK (*sv)) SvIV_set (*sv, SvIVX (*sv) | bits); @@ -402,12 +402,17 @@ #define SDLK_MODIFIER_MIN 300 #define SDLK_MODIFIER_MAX 314 +static AV *texture_av; + MODULE = CFPlus PACKAGE = CFPlus PROTOTYPES: ENABLE BOOT: { + texture_av = newAV (); + AvREAL_off (texture_av); + HV *stash = gv_stashpv ("CFPlus", 1); static const struct { const char *name; @@ -1393,12 +1398,12 @@ if (dx > 0) map_blank (self, self->x, self->y, dx, self->h); else if (dx < 0) - map_blank (self, self->x + self->w + dx + 1, self->y, -dx, self->h); + map_blank (self, self->x + self->w + dx, self->y, -dx, self->h); if (dy > 0) map_blank (self, self->x, self->y, self->w, dy); else if (dy < 0) - map_blank (self, self->x, self->y + self->h + dy + 1, self->w, -dy); + map_blank (self, self->x, self->y + self->h + dy, self->w, -dy); self->ox += dx; self->x += dx; self->oy += dy; self->y += dy; @@ -1462,8 +1467,8 @@ cell->stat_width = *data++ + 1; else if (cmd == 0x47) { - if (*data == 8) - ; // decode player uuid + if (*data == 4) + ; // decode player count data += *data + 1; } @@ -1683,12 +1688,24 @@ // add bits to current tile and all neighbours. skey.x|y is // shifted +1|+1 so we always stay positive. + // bits is ___n cccc CCCC bbbb + // n do not draw borders&corners + // c draw these corners, but... + // C ... not these + // b draw these borders + + // borders: 1 ┃· 2 ━━ 4 ·┃ 8 ·· + // ┃· ·· ·┃ ━━ + + // corners: 1 ┛· 2 ·┗ 4 ·· 8 ·· + // ·· ·· ·┏ ┓· + // full tile skey.x = x + 1; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x1000); // borders - skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0031); - skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0092); + skey.x = x + 2; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0091); + skey.x = x + 1; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0032); skey.x = x ; skey.y = y + 1; smooth_or_bits (smooth, &skey, 0x0064); skey.x = x + 1; skey.y = y ; smooth_or_bits (smooth, &skey, 0x00c8); @@ -1702,7 +1719,7 @@ } } - // go through all smoothlevels, lowest to highest, then draw + // go through all smoothlevels, lowest to highest, then draw. // this is basically counting sort { int w, b; @@ -1723,12 +1740,6 @@ smooth_key *skey = (smooth_key *)HeKEY (he); IV bits = SvIVX (HeVAL (he)); - // bits is ___n cccc CCCC bbbb - // n do not draw borders&corners - // c draw these corners, but... - // C ... not these - // b draw these borders - if (!(bits & 0x1000) && skey->level == level && level >= smooth_max [skey->x][skey->y]) @@ -2366,7 +2377,10 @@ CODE: { GLuint name; - glGenTextures (1, &name); + if (AvFILL (texture_av) >= 0) + name = (GLuint)av_pop (texture_av); + else + glGenTextures (1, &name); RETVAL = name; } OUTPUT: @@ -2375,8 +2389,12 @@ void glDeleteTexture (int name) CODE: { - GLuint name_ = name; - glDeleteTextures (1, &name_); + /* make a half-assed attempt at returning the memory used by the texture */ + /* textures are frequently being reused by cfplus anyway */ + glBindTexture (GL_TEXTURE_2D, name); + glTexImage2D (GL_TEXTURE_2D, 0, GL_ALPHA, 0, 0, 0, GL_ALPHA, GL_UNSIGNED_BYTE, 0); + av_push (texture_av, (SV *)name); + /*glDeleteTextures (1, &name_);*/ } int glGenList ()