--- deliantra/Deliantra-Client/Client.xs 2008/05/20 20:29:47 1.260 +++ deliantra/Deliantra-Client/Client.xs 2008/07/13 12:17:00 1.261 @@ -67,6 +67,15 @@ # include #endif +#if __GNUC__ >= 4 +# define expect(expr,value) __builtin_expect ((expr),(value)) +#else +# define expect(expr,value) (expr) +#endif + +#define expect_false(expr) expect ((expr) != 0, 0) +#define expect_true(expr) expect ((expr) != 0, 1) + #define OBJ_STR "\xef\xbf\xbc" /* U+FFFC, object replacement character */ #define FOW_DARKNESS 32 @@ -79,7 +88,7 @@ /* mask out modifiers we are not interested in */ #define MOD_MASK (KMOD_CTRL | KMOD_SHIFT | KMOD_ALT | KMOD_META) -#if 0 +#if 1 # define PARACHUTE SDL_INIT_NOPARACHUTE #else # define PARACHUTE 0 @@ -1689,7 +1698,7 @@ do { ext = *data++; - cmd = ext & 0x3f; + cmd = ext & 0x7f; if (cmd < 4) cell->darkness = 255 - ext * 64 + 1; @@ -1702,8 +1711,10 @@ cell->stat_width = *data++ + 1; else if (cmd == 0x47) { - if (*data == 4) - ; // decode player count + if (*data == 1) cell->player = data [1]; + else if (*data == 2) cell->player = data [2] + (data [1] << 8); + else if (*data == 3) cell->player = data [3] + (data [2] << 8) + (data [1] << 16); + else if (*data == 4) cell->player = data [4] + (data [3] << 8) + (data [2] << 16) + (data [1] << 24); data += *data + 1; } @@ -1805,7 +1816,7 @@ RETVAL void -draw (DC::Map self, int mx, int my, int sw, int sh, int T) +draw (DC::Map self, int mx, int my, int sw, int sh, int T, U32 player = 0xffffffff, int pdx = 0, int pdy = 0) CODE: { int x, y, z; @@ -1814,6 +1825,10 @@ uint32_t smooth_level[256 / 32]; // one bit for every possible smooth level static uint8_t smooth_max[256][256]; // egad, fast and wasteful on memory (64k) smooth_key skey; + int pl_x, pl_y; + maptex pl_tex; + + pl_tex.name = 0; rc_t *rc = rc_alloc (); rc_key_t key; @@ -1882,7 +1897,8 @@ if (tile) { maptex tex = self->tex [tile]; - int px, py; + int px = (x + 1) * T - tex.w; + int py = (y + 1) * T - tex.h; if (key.texname != tex.name) { @@ -1893,15 +1909,20 @@ arr = rc_array (rc, &key); } - 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); - if (cell->flags && z == 2) + if (expect_false (cell->flags) && expect_false (z == 2)) { // overlays such as the speech bubble, probably more to come if (cell->flags & 1) @@ -2050,6 +2071,23 @@ hv_clear (smooth); } + if (pl_tex.name) + { + maptex tex = pl_tex; + int px = pl_x + pdx; + int py = pl_y + pdy; + + 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); + } + glDisable (GL_BLEND); rc_free (rc);