Deliantra-Client
view release on metacpan or search on metacpan
}
px = (x + 1) * T - tex.w;
py = (y + 1) * T - tex.h;
if (expect_false (cell->player == player) && expect_false (z == 2))
{
pl_x = px;
pl_y = py;
pl_tex = tex;
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);
// update smooth hash
if (tex.smoothtile)
{
skey.tile = tex.smoothtile;
skey.level = tex.smoothlevel;
smooth_level [tex.smoothlevel >> 5] |= ((uint32_t)1) << (tex.smoothlevel & 31);
// 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, 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);
// corners
skey.x = x + 2; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0100);
skey.x = x ; skey.y = y + 2; smooth_or_bits (smooth, &skey, 0x0200);
skey.x = x ; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0400);
skey.x = x + 2; skey.y = y ; smooth_or_bits (smooth, &skey, 0x0800);
}
}
if (expect_false (z == 2) && expect_false (cell->flags))
{
// overlays such as the speech bubble, probably more to come
if (cell->flags & 1)
{
rc_key_t key_ov = key;
maptex tex = self->tex [TEXID_SPEECH];
rc_array_t *arr;
int px = x * T + T * 2 / 32;
int py = y * T - T * 6 / 32;
key_ov.texname = tex.name;
arr = rc_array (rc_ov, &key_ov);
rc_t2f_v3f (arr, 0 , 0 , px , py , 0);
rc_t2f_v3f (arr, 0 , tex.t, px , py + T, 0);
rc_t2f_v3f (arr, tex.s, tex.t, px + T, py + T, 0);
rc_t2f_v3f (arr, tex.s, 0 , px + T, py , 0);
}
}
}
}
rc_draw (rc);
rc_clear (rc);
// go through all smoothlevels, lowest to highest, then draw.
// this is basically counting sort
{
int w, b;
glEnable (GL_TEXTURE_2D);
glBegin (GL_QUADS);
for (w = 0; w < 256 / 32; ++w)
{
uint32_t smask = smooth_level [w];
if (smask)
for (b = 0; b < 32; ++b)
if (smask & (((uint32_t)1) << b))
{
int level = (w << 5) | b;
HE *he;
hv_iterinit (smooth);
while ((he = hv_iternext (smooth)))
{
smooth_key *skey = (smooth_key *)HeKEY (he);
IV bits = SvIVX (HeVAL (he));
if (!(bits & 0x1000)
&& skey->level == level
&& level > smooth_max [skey->x][skey->y])
{
maptex tex = self->tex [skey->tile];
int px = (((int)skey->x) - 1) * T;
int py = (((int)skey->y) - 1) * T;
int border = bits & 15;
int corner = (bits >> 8) & ~(bits >> 4) & 15;
float dx = tex.s * .0625f; // 16 images/row
float dy = tex.t * .5f ; // 2 images/column
if (tex.name)
{
glBegin (GL_QUADS);
}
if (border)
{
float ox = border * dx;
glTexCoord2f (ox , 0.f ); glVertex2i (px , py );
glTexCoord2f (ox , dy ); glVertex2i (px , py + T);
glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py + T);
glTexCoord2f (ox + dx, 0.f ); glVertex2i (px + T, py );
}
if (corner)
{
float ox = corner * dx;
glTexCoord2f (ox , dy ); glVertex2i (px , py );
glTexCoord2f (ox , dy * 2.f); glVertex2i (px , py + T);
glTexCoord2f (ox + dx, dy * 2.f); glVertex2i (px + T, py + T);
glTexCoord2f (ox + dx, dy ); glVertex2i (px + T, py );
}
}
}
}
}
}
glEnd ();
glDisable (GL_TEXTURE_2D);
key.texname = -1;
}
hv_clear (smooth);
}
if (pl_tex.name)
{
maptex tex = pl_tex;
int px = pl_x + sdx;
int py = pl_y + sdy;
key.texname = tex.name;
arr = rc_array (rc, &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);
rc_draw (rc);
}
rc_draw (rc_ov);
rc_clear (rc_ov);
glDisable (GL_BLEND);
rc_free (rc);
rc_free (rc_ov);
// top layer: overlays such as the health bar
for (y = 0; y < sh; y++)
if (0 <= y + my && y + my < self->rows)
{
maprow *row = self->row + (y + my);
for (x = 0; x < sw; x++)
if (row->c0 <= x + mx && x + mx < row->c1)
{
mapcell *cell = row->col + (x + mx - row->c0);
int px = x * T;
int py = y * T;
if (expect_false (cell->player == player))
{
px += sdx;
py += sdy;
}
if (cell->stat_hp)
{
int width = cell->stat_width * T;
int thick = (sh * T / 32 + 27) / 28 + 1 + cell->stat_width;
glColor3ub (0, 0, 0);
glRectf (px + 1, py - thick - 2,
px + width - 1, py);
glColor3ub (cell->stat_hp, 255 - cell->stat_hp, 0);
glRectf (px + 2,
py - thick - 1,
px + width - 2 - cell->stat_hp * (width - 4) / 255, py - 1);
}
}
}
}
void
draw_magicmap (DC::Map self, int w, int h, unsigned char *data)
CODE:
{
static float color[16][3] = {
{ 0.00f, 0.00f, 0.00f },
{ 1.00f, 1.00f, 1.00f },
{ 0.00f, 0.00f, 0.55f },
{ 1.00f, 0.00f, 0.00f },
{ 1.00f, 0.54f, 0.00f },
{ 0.11f, 0.56f, 1.00f },
{ 0.93f, 0.46f, 0.00f },
{ 0.18f, 0.54f, 0.34f },
{ 0.56f, 0.73f, 0.56f },
{ 0.80f, 0.80f, 0.80f },
{ 0.55f, 0.41f, 0.13f },
{ 0.99f, 0.77f, 0.26f },
{ 0.74f, 0.65f, 0.41f },
{ 0.00f, 1.00f, 1.00f },
( run in 0.990 second using v1.01-cache-2.11-cpan-99c4e6809bf )