--- deliantra/Deliantra-Client/Client.xs 2018/11/18 02:04:48 1.325 +++ deliantra/Deliantra-Client/Client.xs 2018/11/18 03:06:13 1.326 @@ -207,7 +207,7 @@ float r, g, b, a; // default color for rgba mode int base_height; DC__Font font; - rc_t *rc; + rc_t rc; }; typedef cf_layout *DC__Layout; @@ -1371,7 +1371,7 @@ DC::Layout new (SV *klass) CODE: - New (0, RETVAL, 1, struct cf_layout); + RETVAL = new cf_layout; RETVAL->pl = pango_layout_new (opengl_context); RETVAL->r = 1.; @@ -1380,7 +1380,6 @@ RETVAL->a = 1.; RETVAL->base_height = MIN_FONT_HEIGHT; RETVAL->font = 0; - RETVAL->rc = rc_alloc (); pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); layout_update_font (RETVAL); @@ -1391,8 +1390,7 @@ DESTROY (DC::Layout self) CODE: g_object_unref (self->pl); - rc_free (self->rc); - Safefree (self); + delete self; void set_text (DC::Layout self, SV *text_) @@ -1656,10 +1654,10 @@ void render (DC::Layout self, float x, float y, int flags = 0) CODE: - rc_clear (self->rc); + self->rc.clear (); pango_opengl_render_layout_subpixel ( self->pl, - self->rc, + &self->rc, x * PANGO_SCALE, y * PANGO_SCALE, self->r, self->g, self->b, self->a, flags @@ -1680,7 +1678,7 @@ glEnable (GL_ALPHA_TEST); glAlphaFunc (GL_GREATER, 7.f / 255.f); - rc_draw (self->rc); + self->rc.draw (); glDisable (GL_ALPHA_TEST); glDisable (GL_BLEND); @@ -2229,10 +2227,10 @@ static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k), also, static! int pl_x, pl_y; maptex pl_tex; - rc_t *rc = rc_alloc (); - rc_t *rc_ov = rc_alloc (); + rc_t rc; + rc_t rc_ov; rc_key_t key; - rc_array_t *arr; + rc_t::array_t *arr; pl_tex.name = 0; @@ -2308,7 +2306,7 @@ tex = self->tex [TEXID_NOFACE]; /* missing, replace by noface */ key.texname = tex.name; - arr = rc_array (rc, &key); + arr = &rc.array (key); } px = (x + 1) * Th - tex.w; @@ -2322,10 +2320,10 @@ continue; } - rc_t2f_v3f (arr, 0 , 0 , px , py , 0); - rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); - rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); - rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); + arr->t2f_v3f (0 , 0 , px , py , 0); + arr->t2f_v3f (0 , tex.t, px , py + tex.h, 0); + arr->t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); + arr->t2f_v3f (tex.s, 0 , px + tex.w, py , 0); // update smooth hash if (tex.smoothtile) @@ -2373,25 +2371,24 @@ if (cell->flags & 1) { rc_key_t key_ov = key; - maptex tex = self->tex [TEXID_SPEECH]; - rc_array_t *arr; + maptex tex = self->tex[TEXID_SPEECH]; int px = x * Tw + Tw * 2 / 32; int py = y * Th - Th * 6 / 32; key_ov.texname = tex.name; - arr = rc_array (rc_ov, &key_ov); + rc_t::array_t &arr = rc_ov.array (key_ov); - rc_t2f_v3f (arr, 0 , 0 , px , py , 0); - rc_t2f_v3f (arr, 0 , tex.t, px , py + Th, 0); - rc_t2f_v3f (arr, tex.s, tex.t, px + Tw, py + Th, 0); - rc_t2f_v3f (arr, tex.s, 0 , px + Tw, py , 0); + arr.t2f_v3f (0 , 0 , px , py , 0); + arr.t2f_v3f (0 , tex.t, px , py + Th, 0); + arr.t2f_v3f (tex.s, tex.t, px + Tw, py + Th, 0); + arr.t2f_v3f (tex.s, 0 , px + Tw, py , 0); } } } } - rc_draw (rc); - rc_clear (rc); + rc.draw (); + rc.clear (); // go through all smoothlevels, lowest to highest, then draw. // this is basically counting sort @@ -2468,22 +2465,20 @@ int py = pl_y + sdy; key.texname = tex.name; - arr = rc_array (rc, &key); + rc_t::array_t &arr = rc.array (key); - rc_t2f_v3f (arr, 0 , 0 , px , py , 0); - rc_t2f_v3f (arr, 0 , tex.t, px , py + tex.h, 0); - rc_t2f_v3f (arr, tex.s, tex.t, px + tex.w, py + tex.h, 0); - rc_t2f_v3f (arr, tex.s, 0 , px + tex.w, py , 0); + arr.t2f_v3f (0 , 0 , px , py , 0); + arr.t2f_v3f (0 , tex.t, px , py + tex.h, 0); + arr.t2f_v3f (tex.s, tex.t, px + tex.w, py + tex.h, 0); + arr.t2f_v3f (tex.s, 0 , px + tex.w, py , 0); - rc_draw (rc); + rc.draw (); } - rc_draw (rc_ov); - rc_clear (rc_ov); + rc_ov.draw (); + rc_ov.clear (); glDisable (GL_BLEND); - rc_free (rc); - rc_free (rc_ov); // top layer: overlays such as the health bar for (y = 0; y < sh; y++)