--- deliantra/Deliantra-Client/Client.xs 2007/04/13 18:11:26 1.180 +++ deliantra/Deliantra-Client/Client.xs 2007/04/26 23:51:02 1.191 @@ -58,6 +58,8 @@ # define PARACHUTE 0 #endif +static AV *texture_av; + static struct { #define GL_FUNC(ptr,name) ptr name; @@ -347,7 +349,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); @@ -616,10 +618,13 @@ ); if (RETVAL) { + av_clear (texture_av); + SDL_WM_SetCaption ("Crossfire+ Client " VERSION, "Crossfire+"); # define GL_FUNC(ptr,name) gl.name = (ptr)SDL_GL_GetProcAddress ("gl" # name); # include "glfunc.h" # undef GL_FUNC + } OUTPUT: RETVAL @@ -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; } @@ -1714,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; @@ -1737,7 +1742,7 @@ if (!(bits & 0x1000) && skey->level == level - && level >= smooth_max [skey->x][skey->y]) + && level > smooth_max [skey->x][skey->y]) { maptex tex = self->tex [skey->tile]; int px = (((int)skey->x) - 1) * T; @@ -2212,6 +2217,9 @@ for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); + + texture_av = newAV (); + AvREAL_off (texture_av); } char * @@ -2372,7 +2380,10 @@ CODE: { GLuint name; - glGenTextures (1, &name); + if (AvFILL (texture_av) >= 0) + name = (GLuint)(size_t)av_pop (texture_av); + else + glGenTextures (1, &name); RETVAL = name; } OUTPUT: @@ -2381,8 +2392,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 *)(size_t)name); + { GLuint name_ = name; glDeleteTextures (1, &name_); } } int glGenList ()